Yelü was a member of the Liao royal family - a dynasty of Khitan tribes that had ruled areas of Inner Mongolia, Outer Mongolia, and Manchuria since the tenth century. The original Liao dynasty was displaced by the Jurchen, a Tungus people native to Manchuria. Yelü led roughly 100,000 of his fellow Khitan in an exodus from Jurchen rule westward to Turkestan. Yelü and his followers arrived in 1124 at the Uyghur capital of Beshbaliq. The Uyghurs - traditional vassals to the Khitans - submitted to Yelü and the army of refugees he led. Yelü, after amassing an army of Uyghurs, Tibetans, Qarluks, and others, fought a series of aggressive wars against his neighbors from his new kingdom and soon seized control of Dzungaria.
Yelü was treated amicably by the Western Xia Dynasty and the Buddhist Kharakojas, but after being rebuffed by the Kara-Khanid Khanate at Gulja and Kashgar, Yelü subjugated the Kara-Khanids and incorporated their lands, Kashgar, Khotan, and Ferghana to his growing kingdom in 1137. Now on the borders of Persia, he made war against the Seljuk Turks and conquered Sogdia, Bactria, Khwarazm, and Samarkand by 1141. The Seljuk state then collapsed into internal rebellion.
His wars against the Muslim Turks in Central Asia, particularly his victory at Samarkand, and his amicable relations with Nestorian Christianity, which flourished in the Kara-Khitan Khanate, led to his association with the legend of Prester John, a Christian king in the east who was "destined" to vanquish Islam. Bishop Otto of Freising first chronicled the story in 1145.