Ala ad-Din Muhammad's alliance with his suzerain was short-lived. He again initiated a conflict, this time with the aid of the Kara-Khanids, and defeated a Qara-Khitai army at Talas (1210), but allowed Samarkand (1210) to be occupied by the Qara-Khitai. He overthrew the Karakhanids (1212) and Ghurids (1215). In 1212, he shifted his capital from Gurganj to Samarkand. Thus incorporating nearly the whole of Transoxania and present-day Afghanistan into his empire, which after further conquests in western Persia (by 1217) stretched from the Syr Darya to the Zagros Mountains, and from the northern parts of the Hindu Kush to the Caspian Sea. By 1218, the empire had a population of 5 million people.