Shahrisabz (“green city”) is located in the upper reaches of the Kashkadarya river to the southwest of Zaravshan ridge (39 ° 03 N, 66 ° 50. E). The first settlement arose here about 2,700 years ago. Since the time of Achaemenids and Alexander the Great, over the mountain pass there was a short cut caravan road to Marakanda (Samarkand) (now there is a highway). In the early Middle Ages the town was known as Kesh and belonged to the community of Sogdian principalities, which in the 5th-7th centuries obeyed the Ephtalites, Turks, and then the Chinese Tang Empire. Under Ishkhid Varhuman (about 650) Kesh recognized the supremacy of Samarkand ruler. Arabic governor Quteiba, in 712, signing a peace treaty with Ihshid Gurek, confirmed the power of Samarkand king over Kesh.
In the 8th century Kesh fiercely opposed the establishment of Arab government and in 770 supported an anti Islamic uprising led by Mukanna. In the 9th century Kesh became one of the centers of Islam and its name was glorified by the hadiths collector Abu Muhammad Abdalah al-Keshi. In the 10th-12th centuries Kesh was a large city under the rule of Samanids and Qarakhanids. In the time of the Mongols Shahrisabz oasis became an independent principality of the Barlas tribe. Amir Temur’s clan was a part of this tribe. That is why the city became the second capital of Temur’s empire, a “dome of science and adab,” and was supposed to outshine Bukhara. In the 18th-19th centuries the Shakhrisabz princedom defended its independence in continual wars with the Bukhara Khanate.