 This region remained under Karakhanid, and for varying periods it remained an independent vassal of Seljuk and Kara-Khitan.The Karakhanid khanate ended when the last ruler of its western Khanate was killed by the Khwarezmids in 1212.Both the Kara-Khitans and the Khwarezmids were later destroyed by the Mongol invasion.