Khwarazmian dynasty
The decline of the Seljuks following their defeat by the Qara Khitans allowed the Khwarazmian dynasty, then a vassal of the Qara Khitai, to expand into former Seljuk territory. In 1207, the citizens of Bukhara revolted against the "sadrs" (leaders of the religious classes), which the Khwarazmshah 'Ala' ad-Din Muhammad used as a pretext to conquer Bukhara. Muhammad then formed an alliance with the Western Karakhanid ruler Uthman (who later married Muhammad's daughter) against the Qara Khitai. In 1210, the Khwarezm-Shah took Samarkand after the Qara Khitai retreated to deal with the rebellion from the Naiman Kuchlug, who had seized the Qara Khitans' treasury at Uzgen. The Khwarezm-Shah then defeated the Qara Khitai near Talas. Muhammad and Kuchlug had, apparently, agreed to divide up the Qara Khitan's empire. In 1212, the population of Samarkand staged a revolt against the Khwarezmians, a revolt which Uthman supported, and massacred them. The Khwarezm-Shah returned, recaptured Samarkand and executed Uthman. He demanded the submission of all leading Karakhanids, and finally extinguished the Western Karakhanid state.