Human settlement of the region dates from Neolithic times, but the development of Tehran was very slow and its rise to prominence largely accidental. In AD 1197, after Mongols sacked and destroyed nearby Rey - the major urban centre in Persia at the time - Tehran began to develop in its place. From the mid-16th century, Tehran's attractive natural setting and good hunting brought it into the favour of the Safavid king, Tahmasb I. It developed from a moderately prosperous trading village into an elegant, if dusty, city and European visitors wrote of its many enchanting vineyards and gardens. In 1789, Agha Mohammad Khan declared Tehran his capital, and six years later had himself crowned as shah of all Persia. The town continued to grow slowly under later Qajar rulers.