 In 1124 , just before the final conquest of the Liao dynasty , a group of Khitans led by Yelü Dashi fled northwest to the border area and military garrison of Kedun ( Zhenzhou ) , in modern @-@ day northern Mongolia . Yelü Dashi convinced the people there , around 20 @,@ 000 Liao cavalry and their families , to follow him and attempt to restore the Liao dynasty . Yelü Dashi proclaimed himself emperor in 1131 , after which he moved further west into modern Kazakhstan and then occupied the Karakhanid city of Balasaghun ( in modern Kyrgyzstan ) . After a failed attempt in 1134 to reclaim the territory formerly held by the Liao , Dashi decided instead to stay where he was and establish a permanent Khitan state in Central Asia . The state , known as the Qara Khitai or the Western Liao dynasty , controlled several key trading cities , was multicultural , and showed evidence of religious tolerance . The state survived for nearly a century before being conquered by the Mongol Empire in 1218 . 
