In the year 1124, an ambitious prince in northern China named Yelü Dashi faced a pivotal decision—stay and make a final stand with his people, who faced near-certain defeat, or head for the hinterlands in search of new prospects. Just a decade earlier, Dashi had been a junior member of the Yelü royal clan of the Khitan, the nomadic group that ruled the Liao Empire. The empire had been founded in a.d. 907 by Abaoji, a direct ancestor of Dashi’s. Abaoji united the Khitan tribes, who were based in eastern Mongolia and parts of China, and rallied them to conquer much of northern Asia, from the border of the Korean Peninsula across portions of northern China, southern Siberia, and Mongolia. This territory included both traditionally Chinese areas that were home to settled farmers and great stretches of steppe where other nomadic tribes roamed. The Khitan maintained their nomadic lifestyle, and their emperors and courts moved among five different capitals. They established a hybrid style of government: An administration in the south, staffed by civil servants, many of them Chinese, was responsible for the largely Chinese parts of the empire, and a northern administration tended to the nomadic tribes of the steppe.
After initially clashing with their southern neighbors, the Chinese Song Dynasty (a.d. 960–1279), in 1005 the Liao made peace with the Song on terms that left a contested border region in Liao hands. The Song also agreed to make substantial annual payments to the Liao and to recognize the Liao emperor as a Son of Heaven, on par with the Song emperor. Wrangling the nomadic tribes in the north, however, grew increasingly challenging. These tribes were compelled to pay taxes to the Liao, a burden that became particularly onerous in the early twelfth century as the climate grew harsher. The Jurchens, a north Manchurian tribe who were expected to procure special gyrfalcons that the Liao emperor used for hunting, grew so frustrated with these demands that they rebelled in 1114. The next year, they founded the Jin Dynasty (1115–1234) and began taking over Liao lands in Manchuria. Around this time, Dashi was launching his career. He had pursued an education typical of the Khitan elite, mastering horse riding and archery as well as the Khitan and Chinese scripts. He had passed all the Chinese imperial examinations and, just as the Liao Empire began to fall apart, he took on a series of administrative and military roles, largely along the Liao-Song border.