At the turn of the 10th-11th centuries, the Samanid state was smashed by armies of Turkic dynasties -Qarakhanids and Ghaznavids.
The population had grown up to 100 thousand. A new palace was built in the citadel. The cathedral mosque was restored. Streets in shahristan were improved. The tomb of Kussam-ibn-Abbas obtained cultic significance and was supplied with a mausoleum. Beside, the mosque and madrasah of Tomgach Bogra Khan from the Qarakhanids were built. This one-storey building of yard-aivan type is the earliest among Central Asian madrasah. At the first half of the 12th century, sheikh Ahmad al-Hamadani, founding Sufi traditions of “khadjagan-naqshbandiyyah" and "yassaviyyah" was preaching in Samarkand. At the beginning of the 13th century, the last Qarakhanid ruler, Usman constructed the mausoleum for his father, Abraham ibn Hussein on Afrasiab.
At the last quarter of the 11 th century, the Qarakhanids had to recognize dependence on another Turkic dynasty - Great Seljuks, which conquered the western lands of the Islamic world. In 1141, the Qarakhitai smashed the army of Seljuk sultan Sandjar and his vassal, Qarakhanid Mahmud Khan in the battle near Samarkand. Tens of thousands warriors, which lost in this battle, were burled at Samarkand holy cemetery of Choqardiza. The Qarakhanids managed to keep their authority in Samarkand, but recognized their vassalage on the Qarakhitai. At the beginning of the 13th century, political supremacy in Central Asia switched to Khorezmshahs, which subordinated the last Qarakhanids and took Samarkand. In the citadel, on the place of the Qarakhanid palace, Khorezmshah Mohammed built a new palace decorated with wall paintings.
Invasion of Mongols led by Genghis Khan became terrible ordeal for Central Asia. In 1220, having taken Bukhara, the armies of Genghis Khan arrived at fortified Samarkand. The city was defended by 150-thousand garrison and 20 charger elephants. Genghis Khan simulated an assault and flushed defenders from the city, where the main body of Mongols smashed them. The Mongols army laid a siege, shelling the city from bows and catapults. Then, the Islamic clergy sent an embassy to Genghis Khan and, having stipulated for security of their people, opened gates before Mongols. The most part of citizens were taken prisoners, craftsmen were moved to Mongolia. Taoist monk Chang-Chun witnessed that at re end of 1221, just a quarter of the population had remained in Samarkand. However, the city had not been ruined totally yet. Bazaars were operating, and the Mongolian governor lived at the palace of Khorezmshah. Genghis Khan conquest brought Central Asia to the domain (ulus) of his son - Chagatai. Like the other cities of Maverannahr, Samarkand was strongly damaged because of internecine feuds among the Genghisids at second half of the 13th century. Afrasiab had been entirely deserted. Revival of Samarkand fell to the end of the 13th-beginning of the 14th centuries, when was established Chagatai ulus, but the urban life switched to the place of former southern rabad (suburb).