# History of the Khitans

The history of the Khitans dates back to the 4th century. The Khitan people dominated much of northern China, Manchuria and the Mongolian Plateau. They subsequently established the Liao dynasty and the Western Liao dynasty.
Originally from Xianbei origins, the Khitans were part of the Kumo Xi tribe until 388 when the Kumo Xi–Khitan tribal grouping was defeated by the newly established Northern Wei dynasty. This allowed the Khitans to reorganize and consolidate their own tribal identity which led to the beginning of Khitan written history.
From the 5th to the 8th centuries, the Khitans were dominated by the Turks and then the Uyghurs in the west, various Central Plain dynasties in the south, and Goguryeo in the east. Despite coming under the domination of other polities, the Khitans grew in power. Their rise was slow compared to others because they were frequently crushed by neighbouring powers—each employing the Khitan warriors when needed but ready to crush them when the Khitans became too powerful.
Following the collapse of the Tang dynasty in the early 10th century, they founded the Liao dynasty in 916. The Liao dynasty proved to be a significant power north of the Central Plain and it gradually expanded to occupy other territories including the Sixteen Prefectures. They eventually fell to the Jin dynasty in 1125, who subordinated and absorbed the Khitans to their military benefit.
Following the fall of the Liao dynasty, many Khitans migrated westward and established the Western Liao dynasty. Although the Khitans no longer survive as a distinct ethnic group in contemporary times, their name is preserved in the Russian word for China (Китай, Kitay) as well as the archaic English (Cathay) Portuguese (Catai) Hungarian (Kína) and the Spanish (Catay) appellations of the name.

## Origins

References to the Khitan people in Chinese sources date back to the 4th century. After their regime was conquered by the Murong clan the remnants scattered in the modern-day Inner Mongolia and mixed there with the original Mongolic population.

## Pre-dynastic Khitans (388–916)

During the time of the Chinese Tang dynasty, the Khitan people were vassals to the suzerain Tang or Turks, depending on the balance of power between the two, or the suzerain Uyghurs when they replaced the Turks as the main steppe power. Once the Uyghurs left their home in the Mongolian Plateau in 842 enough of a power vacuum was left to give the Khitan the opportunity to cast off the bonds of subordinacy. The Khitan occupied the areas vacated by the Uyghurs bringing them under their control.

### Khitan military activities from 388 to 618

In the 5th century, the Khitan were under the Toba Wei influence.
In the 6th century, the Khitan tribes were still a weak confederation after being heavily defeated in 553 by the Northern Qi who enslaved many Khitans and seized a large part of their livestock, leading to harsh times for the Khitans. By that time the Khitan are still described as the lower level of nomadic civilization, their 'confederation' still being an anarchist system of isolated tribes, each tending his own sheep and horses and hunting on his private territory. Some federal leaders were created after elections during a time of war after which it became a local power.
When the Sui dynasty was established in 581 when the Khitan were living in a period of internal military turmoil. Their tribes were fighting each other perhaps as a result of Sui Wendi strategy to increase tensions between nomads in order to create internal divisions. In 586 some Khitans tribes submitted to the Eastern Tujue (Turks) while others submitted to the Sui.
Notable Khitan raids on the Chinese Empire were record as early as the 7th century. In 605 they staged a large-scale raid southward invading Sui territories (Northern modern Shanxi, Hebei). They were eventually crushed by a Sui general leading 20,000 Turkish cavalry.

### Military activities during the first half of the Tang dynasty (618–735)
#### The Li-Sun Rebellion (696–697)

Under Emperor Taizong of Tang (r. 626–649) the Khitans became vassals of Tang dynasty. Despite some occasional clashes, the Khitans remained Chinese vassals until the 690s when Empress Wu took the throne of China. According to the "Loose rein policy", the Khitan area was under Tang's control by Zhao Wenhui, the governor-general of Yingzhou. Zhao was assisted by two local Khitan chieftains: Li Jinzhong, the governor (Dudu) of Songmo protectorate, and Duke of Yongle County, Sun Wanrong, who was the brother-in-law of Li Jinzhong.
Opposition rose because of the behaviour of Zhao Wenhui, who treated Khitan chieftains as his servants and refused to provide help during a famine that struck the Khitan area in 696. According to the "loose rein policy" the Tang governor-general was supposed to provide famine relief. When Zhao Wenhui failed to do so, Li and Sun launched a Khitan rebellion in the fifth month of 696.
Li Jinzhong declared himself "Wushang Kehan" (無上可汗: "paramount khaghan") and killed Zhao Wenhui after capturing Yingzhou. Sun Wanrong assisted him as general who successfully led tens of thousands of troops marching southward and conquered several other towns of Tang dynasty.
The first significant Chinese response was to send an army led by twenty-eight generals, but they were defeated by Khitans in the Battle of Xiashi Gorge (near modern Lulong County of Hebei Province) in the eighth month of 696. Empress Wu was astonished by the announcement of the defeat and she quickly issued decrees to launch a new attack to the rebels. Khitans kept winning on the battlefields until Li Jinzhong died of disease. The rising power of the Khitans also threatened the newly established Second Turkic Khaganate, and the khagan Qapaghan Qaghan (Ashina Mochuo), who had supported the Khitan rebellion, switched to Empress Wu's side after the Chinese gave him several promises including an imperial marriage for his daughter, adoption as the son of Empress Wu, the relocating of his people to (Hexi Corridor) and the restoration of Turkish overlordship of the Khitans.
The second major counter-attack from Empress Wu to the Khitans came in October 696, taking advantage of the recent death of Li Jingzhong. This time, Tang forces planned to attack Khitan from the south and the Turks would also invade Khitan from north. The Khitans suffered heavy losses in this campaign, but Sun Wanrong managed to stand still and motivated the Khitan troops. The rebellion of Khitans continued and Sun Wanrong's men stormed into Jizhou and Yingzhou, shaking the whole region of Hebei. Empress Wu sent one of his best generals, Wang Xiaojie, assisted by Su Honghui and some other top warriors, with a third army of 170,000 men, to put down the rebellion. Due to the unfamiliarity to the local geography and terrains, Wang Xiaojie's force was ambushed by Sun Wanrong at the Dongxia Rocky Valley (东峡石谷). Wang Xiaojie was killed while Su Honghui fled away. After that, Khitans captured Youzhou (near today's Beijing), which was an important gateway to the northern plain of China.
In a fourth campaign during May 697, Empress Wu sent Lou Shide and Shatuo Zhongyi with 200,000 troops to stop Sun Wanrong's from going further south. Khitans tried to ask for reinforcement from Turks. However, Turks refused the proposed Khitan-Turk alliance. Instead, they somehow allied with Empress Wu and launched a massive attack on Khitans. Meanwhile, Kumo Xi, another minority group who initially allied with Khitan in this rebellion, switched to Tang. Khitans had to face devastating Turkish raids from the north while a 200,000-men Chinese and Xi allied force attacking from the south. In this critical situation, Sun Wanrong was assassinated by one of his own subordinates, and the Khitan force collapsed. After this rebellion, Khitans began a new allegiance with the Turks as Qapaghan and the Empress Wu had planned early in 696. Empress Wu also appointed a new Khitan chieftain, whose name was Li Shihuo (697–717, [李]失活).
Consequently, Turks broke away with Empress Wu (who handed the crown back to the royal clan of Tang in 705). Tang launched several campaigns against them from 700 to 714 and eventually the khanate of Turks was overthrown by Uighurs who was supported by Tang dynasty.

#### The Li-Sun rebellion and the Turks

The Turks played a major role in crushing a rebellion in military actions and in a strategic role as well. The Turks were to submit to China in 630 after their first Turkish Empire was crushed. In 679 during a period of Chinese internal political turmoil they revolted. They were defeated by Tang troops in 681 in a Pyrrhic victory, also, the remaining Eastern Turks reunited under Ilterish Qaghan (Ashina Gutulu) (died 691) who was able to proclaim the rebirth of the Turkish empire without Tang's reaction.
When Li-Sun died, his brother-in-law Sun Wanrong replaced him and engaged the Turks in an aggressive policy of "plunder to strengthen" as the best way to revitalize his Empire. The Turks plundered all their neighbour, the Khitan and Chinese included, but encouraged the Khitans to rebel against Tang rule. Almost as soon as the Khitan rebelled and were successful the Turks proposed an alliance with China. The Turks, engaged in a war against China, were just asking the Khitans for a diversion in the east allowing them to be more free on their front. When the Khitans unexpectedly appeared to be successful they both were surprised and afraid at seeing a new power born on their East. Seeing the Khitans fighting hard against the Chinese seemed the perfect occasion to take advantage of both the busy Khitan and the downtrodden Tang. By attacking Khitan on their rear the Turks provided an inestimable help to Tang which also worked for themselves by crushing that eastern rising power.
While the fourth Chinese campaign was still not launched, and despite previous propositions of alliance, the Turks attacked the Chinese territories to show clearly they were strong in the third month of 697. Along with the final victory they freed some Turkish prisoners held in six Chinese northern border prefectures since 670–674, gained the submission of both the Khitan and the Xi, plundered a large amount of seed-grain, silk, farming implements and iron as well as winning noble titles for Qapaghan and the asked for imperial marriage with Wu Zetian.

#### The Ketuyu rebellion (720–734)

In the 710s the Khitan military chief Ketuyu (可突于) was so valiant and beloved by Khitan's commoners that the Khitan King Suogu (李娑固 Li Suogu, r. 718–720) became both jealous of him and in fear of a take-over. Accordingly, he plotted to assassinate Ketuyu. As is often the case the plot was disclosed and Ketuyu's troops attacked the King who fled to Yingzhou to get Chinese support.
Xu Qinzhan (許欽?), the Chinese governor-general of Yingzhou, immediately called for a punitive military campaign ordering General Xue Tai assisted by 500 valiant soldier, Xi troops, and Suogu troops to go northwards. The Chinese-loyalist army was crushed and both Suogu (Khitan King) and Li Dapu (Xi King) were killed while Xue Tai was captured by Ketuyu. In hope of resuming good relations with the Chinese Tai was not executed and an envoy was sent to humbly apologize while Ketuyu enthroned Suogu's cousin Yuyu (李鬱于, 720–722/724).
Peaceful relations were restored and when Ketuyu made a second coup to face the new king Tuyu suspicions, the Tang court peacefully confirmed the newly enthroned king Shaogu (李邵固 Li Shaogu, 725–730) who on his side displayed respect for Tang's wishes of appeasement.
In 730 Ketuyu went to present tributes to Chang'an but was mistreated by chancellor Li Yuanhong. Back in the Khitan territories Ketuyu assassinated the pro-Tang Shaogu in the fifth month of 730 and switched the allegiance of his subjects, and of the Xi tribes, from Tang to the Türks sending a clear message to Tang. Ketuyu then attacked Pinglu (part of Yingzhou) where a defensive army of Tang's was stationed. The Chang'an officials were panicked by the vision of a new Khitan rebellion and ordered Prince of Zhong Jun, as commander in chief assisted by 18 generals, to go north with warriors recruited from as far as Guannei, Hedong, Henan and Hebei to crush this Khitan-Xi rebellion.
In the third month of 732 the Khitan-Xi troops were defeated by the Prince of Xin'an and Ketuyu had to flee while Li Shisuogao(李詩瑣高), the Xi king, betrayed him submitting to Tang with his 5,000 subjects getting the titles of the Prince of Guiyi (allegiance and righteousness) and prefect of Guiyi Zhou with the Xi allowed to settle in Youzhou under Chinese protection.
A second major campaign came in the fourth month of 733 when Guo Yingjie was ordered to lead 10,000 troops, assisted by Xi warriors, to crush Khitan. Ketuyu came first with Turkish support putting the Chinese-Xi troops in difficulty forcing the Xi to flee to save themselves. Predictably Guo Yingjie and his men, left alone to face the Khitan-Turkish troops, lost with heavy casualties. Guo and most of his men were killed on the battlefield. One year later the Khitan were defeated by Zhang Shougui, regional commander of Youzhou in the second month of 734.
Ketuyu, seeing the Khitan forces exhausted by repetitive Tang campaigns, pretended to surrender in the twelfth month of 734 and was murdered, together with his puppet King Yaonian Qulie (遙輦屈列, 730–734), by his subordinate Li Guozhe (李過折). Li Guozhe was soon himself assassinated in favor of a Ketuyu clan restoration.

#### Origins of the Ketuyu Rebellion

While traditional scholars explain this Ketuyu Rebellion as a typically barbarian reaction modern historians are more cautious. Both the Chinese Liao expert Shu Fen and the Japanese Matsui Hitoshi are inclined to think that Chinese lenient policy encouraged Ketuyu's arrogance. In contrast, Xu Elian-Qian supports the theory that Chinese interferences in Khitan internal changes caused the aggression to Ketuyu's reactions. That may be true for the conflict of 720 and the aggressive Chinese behaviour. But this opinion does not explain the Chinese appeasement policy in 725 where the Chinese let Ketuyu kill the Khitan king and enthrone a new one. When Ketuyu was personally mistreated, in Chang'an in 730, this resentment led him to choose the larger of consequence of diplomatic opposition by turning his submission to the Turks. This was predictably understood by Chang'an as a first magnitude treason which could not be tolerated and lead to the ensuing five years of war to recapture them. Shu and Matsui do not see this Chinese reaction as an aggressive interference but rather as a predictable interference caused by Ketuyu's arrogant reaction to the recent lenient policy.
Xu explains that the Khitans were at a turning point. The Dahe family collapsing as an after-shock of the Li-Sun Rebellion while the Yaonian family was growing by organizing a new confederation of alliances. Accordingly, this period was rich in turmoil. The opposition may have come from the respective perceived definition of the Loose rein agreement. In times of weakness in the central power, such as in the 680's, this loose rein policy meant largely independence for the subordinate population who chose their own chief etc. In times of strong central power, as under Tang Xuanzong (r. 712–756), the central Chinese power was inclined to impose pro-Chinese choices, including in choice of Kings and major chiefs, despite the previous loose rein agreement. Also in prosperous times such as Xuanzong's reign, and his courage in facing the 720's coup, Tang officials immediately sent an army to support the dethroned pro-Tang king clearly interfering in Khitan internal affairs.
The 730–734 war seems to have been the consequence of both Chinese revitalized foreign policy, Khitan internal turmoil and associated oppression of Ketuyu and the miscalculations made by him.

### An Lushan era (750s)
#### Rise of An Lushan and Chinese-on-Khitan hostilities

By the 730s regional commanders already have largely autonomy of initiative to face neighbouring threats and accordingly boundary wars and rebellions are understood by many scholars as the full responsibility of local general commanders.
In the third month of 736 Zhang Shougui, the general commander of Youzhou, sent his protected An Lushan, an officer of the Pinglu Army (平盧軍) based in modern Chaoyang who was said to know 6 languages of Chinese, to attack Khitan and the Xi rebels but An Lushan made an overtly audacious attack which cost him almost all of his troops. He escaped the usual execution for such disobedience cases in part because of Zhangs affection for him and in part thanks to Emperor Xuanzong who, overviewing death penalty cases, believed that his audacious and mid-barbarian character should not pay by death.
Youzhou soon became the Bingmashi (兵馬使) of the Pinglu Army in the seventh month of 741. He carefully cultivated relationships with other officials and generals to earn praises and bribed Imperial messengers to include him in their reports. As the consequence of this systematic bribery he was promoted to commandant at Yingzhou (Ying prefecture) and Jiedushi (military governor) of the Pinglu army in 742 to face and defeat the northern threat from Khitans, Xi, Balhae and Heishui Mohe. He was made military governor of Fanyang Circuit (范陽, headquartered in modern Beijing) in 744 plundering Khitan and Xi villages to display his military abilities. This continuous harassment of Khitan is understood by some scholars as provocation to the Khitan aggressiveness and the threat aimed to get more troops from Chang'an for his future rebellion as well as the reason for the 745 Khitan-Xi rebellion.
As commander of the northeastern frontier in 744–755 An Lushan organised military operations against the Khitan-Xi nomads. His motivation was to curry favour with the Tang court and probably also to obtain more troops. He needed these for his subsequent campaigns to defeat what he saw as the enormous threat presented by the northeastern "barbarians" amongst who the Khitan were the most significant. He may also have been motivated by thoughts of preparing for his future rebellion of 755–763.
The rebel An Lushan had a Khitan eunuch named Li Zhu'er (李豬兒) (Li Chu-erh) who was working for An Lushan when he was a teenager but An Lushan used a sword to sever his genitals as he almost died losing multiple pints of blood. An Lushan revived him after smearing ashes on his injury. Li Zhu'er was An Lushan's eunuch after this and highly used and trusted by him. Li Zhu'er and another 2 men helped carry the obese An Lushan when he was taking off or wearing his clothes. Li Zhu'er helped cloth and take of his clothes at the Huaqing (Hua-ch'ing) steam baths granted by Emperor Xuanzang. Li Zhuer was approached by people who wanted to assassinate An Lushan after An Lushan became paranoid and blind, stricken with skin disease and started flogging and murdering his subordinates. An Lushan was hacked to death in his stomach and abdomen by Li Zhuer and another conspirator, Yan Zhuang (Yen Chuang) (嚴莊) who was beaten by An before. An Lushan screamed "this is a thief of my own household" as he desperately shook his curtains since he could not find his sword to defend himself. An Lushan's intestines came out of his body as he was hacked to death by Li Zhuer and Yan Zhuang. A horse was once crushed to death under An Lushan's sheer weight due to his fatness.

#### 745s Khitan rebellion

In the third month of 745 several Tang princesses were married to Khitan's leaders in a sign of appeasement. But for some reason the Khitans soon turned into an open rebellion against Tang in the ninth month of 745 killing the princesses and starting military operations. Huge previous pressures from An Lushan combined with the Chang'an courts praise for him may have been seen Khitan as presenting an impasse against which they eventually revolted.
The Khitans were quickly defeated by An Lushan's troops by punitive expeditions and traps. Sources report that Banquets for a peace declaration were set up by An Lushan and offered to Khitan and Xi who, happy to get both peace and free provisions, rushed to the buffet and drunk heavily. It turned out that the food and wine were poisoned by narcotics. An Lushan then led his warriors to kill all of those who were sleeping on the ground or drunk enough to be easy to kill and the Chiefs' heads were sent to the Tang court for display. Sources have said that each of such Banquets ended with the death of thousands of warriors. This claim is difficult to believe: can Khitan have been that naive to let An Lushan kill thousands of them, several times, in the same kind of "free food traps". The difficulty is that Chinese sources seem biased against An Lushan depicting him by this story as a terrible untrustable enemy. The final result was that Khitan's 745 rebellion was crushed.

#### 751–752s wars to 755s An Shi rebellion

In 751–752, following An Lushan's provocations and harassment, the Khitans moved south to attack the Chinese Tang Empire. Accordinglys Khitan were soon subject to a Chinese campaign in the eighth month of 751: An Lushan assisted by 2,000 Xi guides leading 60,000 Chinese troops into Khitan territories. When the fighting started the Xi suddenly turned their support to Khitan and the Khitan-Xi army then quickly pushed against the Tang armies who were hampered by rains. The Khitan-Xi army killed almost all the enemy soldiers while An Lushan escaped to Shizhou with just twenty cavalrymen. The defending general Su Dingfang, a Tang general, was eventually able to stop the Khitan pursuit troops which retreated. They had their battlefield victory, although not An Lushan's head, and so they laid siege to the city which only Shi Siming (one An Lushan's general) was able to end. One of his generals was killed in action and, after retreating, he blamed and executed the other two for the defeat.
In 752, to punish this audacity and insult, a 200,000 strong army including both Chinese and barbarian infantry and cavalry went northwards to meet the Khitan. But while An Lushan requested that the ethnically Tujue general Li Xianzhong (李獻忠) accompany him Li feared An and, when compelled to, rebelled putting a halt to An's campaign. After three years in the month fourth of 755 An announced his victory about which historical records are not very clear. By this time An Lushan was already engaged in an opposition to the Yang clan located in Chang'an which turned around his system of alliances. Put into an impasse he rose into rebellion and had to walk southwards to quickly beat the unprotected heartland of the Tang territories. In this movement he looked for assistance from the northern nomads: Tujue, Uighurs, Khitan, Xi and Shiwei. All, to some extent, assisted his troops and his rebellion, Khitan principally by his previously taken prisoners'. But the Khitan were exhausted and took little part in these campaigns.

##### Background reasons of these oppositions

The continuous agitation of Khitans on the northeast of the Empire, maintained by An Lushan actions, provided An Lushan more and more support troops from Chang'an for his own power and ambitions growing to 160,000–200,000 men. This was caused by several factors:
* An Lushan seemed to be a clever military official especially skilled to set up good relationships with his superiors, whatever by systematic brides (as say sources) or by his possible real abilities;
* An Lushan was skilled to both: up Khitan's aggressivity, enlarge the threat in his rapports, and trap/crush them, getting large praises
* the time (740s) was an apogee of prosperity, the treasury was full, the Chinese Empire was at a maximum of extension, Xuanzong and Chang'an officials sur-estimated their own power and displayed growing mark of lazy behaviour and management: waste of financial resources, lack of troops in the Central area;
* in Chang'an, the high chancellor Li Linfu, facing to the rise of the Yang clan in Chang'an, wanted both to resist the Khitans' pressure and counterbalance the growing influence of the Yang clan in Chang'an affairs.
Accordingly, An Lushan's power strengthened with associated pressure on the Khitan.
The turning point came when An became worried about the post of Xuanzong-Li Linfu (An Lushan add "get their favor", but at the cost of relations with other officials). Noticing that the heart of the empire was without defenses An considered to plan a rebellion. He selected a dozen able generals and some 8,000 soldiers from amongst the surrendered Khitan, Xi, and Tongluo (同羅) tribesmen organizing them into an elite corps known as the Yeluohe (曵落河, "the brave").
When Li Linfu died and Yang Guozhong, a Yang clan member, replaced him as high chancellor An Lushan rose in rebellion with his armies and attacked the central power with Khitan, Xi and Turkish supporters.

### 2nd half of the Tang dynasty (763–907)
#### Middle of Tang's dynasty

The Khitan were concentrating themselves on their own development and were relatively peaceful.

#### Uighurs domination and Khitans state

When the Turks were overthrown by the Uighurs in 745, the war-loving power of the Turks was replaced by the commerce-loving Uighurs. The control that the Uighurs had on the Khitans were of a different kind. Uighurs were focusing on economic exchanges, were the protectors of the diplomatic stability and left large political and internal freedom to their vassals. The Khitans used this to keep a peaceful environment helping to strengthen all their demographic, economic and structural force.
For their demographic the main point was the choice to avoid foreign conflicts. The new "Steppe Lords" were relatively peaceful while the Tang dynasty was later greatly weakened by the An-Shi rebellion of 755–763 providing a new intra-China situation with a weak center and with provincial generals pacification and strengthening of their respective provinces. In this context the Khitans and their close-relatives the Xi had opposite strategies. Kumo Xi kept a relatively aggressive foreign policy slowly exhausting their forces. The Khitans chose to stay as a calm self-defensive power enjoying most of the Manchurian plain and working to improve their daily situation. While previous centuries had seen successive Turko-Chinese provocations or recall to obeisance, and the following wars had prevented Khitan gaining any notable expansion, the 8th-century situation eventually allowed one. This demographic growth would strongly support the other qualitative changes.

### Pre-dynastic Khitan's allegiances and reasons

* Pre-388 : Kumo Xi – submitted to the Turks. Part of the Kumo Xi-Khitan tribal complex
* 388–?: Later (383–409) and Northern Yan (409–436) – a result of the 388 Kumo Xi defeat facing the Northern Wei
* 479–?: Northern Wei – to avoid a Rouran-Goguryean invasion
* 560s(?)–?: some tribes submitted to Goguryeo to avoid Northern Qi and Eastern Turk threats;
* 648–696: Tang dynasty– because of recent Tang expansion and following the Turkish collapse.
* 696–697 : independent (Li-Sun Rebellion) and in war on all sides, encouraged by Tujue and caused by Chinese official mistreatment and famine.
* 697–720s : Tang dynasty+ Tujue, since the 697 defeat.
* 730–734: Turks – Ketuyu Rebellion caused by Tang interventionism and Tang's chancellors mistreatment.
* 734–? : Tang dynasty – because of recent defeat.
* To complete

## Liao dynasty (916–1125)

The Liao dynasty was founded in 916 when Abaoji, posthumously known by his temple name as Emperor Taizu, was named the leader of the Khitan tribal confederation. The dynastic name "Great Liao" was proclaimed in 947 by his successor, the Emperor Taizong of Liao.
Though Abaoji died in 926 the dynasty would last nearly two more centuries. Five cities were designated as capitals during that dynasty. In addition to the supreme capital in the heartland of Khitan territory there were four regional capitals. One of which was Beijing which became a capital for the first time in its history. It was not the principle capital of the dynasty but rather was designated as the southern capital after the Khitan acquired the contentious Sixteen Prefectures in 935.
Abaoji introduced a number of innovations – some more successful than others. He divided the empire into two parts: one was governed based on nomadic models while the sedentary population was governed largely in accordance with Chinese techniques. Less successful was the attempted introduction of primogeniture in succession to the throne. Although he desired his eldest son to be heir he did not succeed Abaoji.
Abaoji was "afraid that their use of Chinese advisers and administrative techniques would blur their own ethnic identity, the Khitan made a conscious effort to retain their own tribal rites, food, and clothing and refused to use the Chinese language, devising a writing system for their own language instead." The first of these two scripts was created in 920. The second, based on alphabetic principles, was created five years later.
Before the Jurchens overthrew their Khitan rulers, married Jurchen women and Jurchen girls were raped by Liao dynasty Khitan envoys as a custom which caused resentment by the Jurchens against the Khitan. Liao Khitan envoys among the Jurchens were treated to guest prostitutes by their Jurchen hosts. Unmarried Jurchen girls and their families hosted the Liao envoys who had sex with the girls. Song envoys among the Jin were similarly entertained by singing girls in Guide, Henan. Although the Liao Khitan had superior power over the Jurchens when ruling them there were no evidence that guest prostitution of unmarried Jurchen girls to Khitan men was hated or resented by the Jurchens. It was only when the Liao Khitan forced aristocratic Jurchen families to give up their beautiful wives as guest prostitutes to Liao Khitan messengers stirred resentment and anger by the Jurchens. A historian has speculated that this could mean that in Jurchen upper classes, only a husband had the right to his married wife while among lower class Jurchens, unmarried girls virginity and sleeping with Liao Khitan men did not matter and did not impede their ability to marry later. The Jurchens sexual habits and norms were seemed lax to Han Chinese, such as marrying with an in-law, which was one of China's "Ten Heinous Crimes". Jurchens very commonly practiced guest prostitution giving female companions, food and shelter to guests. Unmarried daughters of Jurchen families of lower and middle classes in native Jurchen villages were provided to Liao Kitan messengers for sexual intercourse and amusement as recorded by Hong Hao (Hung Hao). Marco Polo also reported that Hami (Camul) guest prostitution was practiced with hosts giving their female relatives, sisters, daughters and wives to guests in their house. Tanguts practiced this guest prostitution.

## Post-Liao dynasty history

The Khitans were absorbed by the Jurchens and widely used in the following years of war to conquer the northern Song territories.
In contrast a number of the nobles of the Liao dynasty escaped the area towards the Western Regions establishing the Qara Khitai (Western Liao dynasty). They were in turn absorbed by the local Turkic and Iranian populations and left no influence of themselves. As the Khitan language is still almost completely illegible it is difficult to create a detailed history of their movements. The Khitans were mainly employed by the Mongols in military and civil services after they conquered most of Eurasia. The Daur people and some Baarin people are direct descendants of the Khitans.
On the Eastern front, Khitans elements fled the Mongol offensives toward Korea. In 1216 the Khitans invaded Goryeo and defeated the Korean armies multiple times, even reaching the gates of the capital and raiding deep into the south, but were defeated by Korean General Kim Chwi-ryeo who pushed them back north to Pyongan, where the remaining Khitans were finished off by allied Mongol-Goryeo forces in 1219. These Khitans are possibly the origin of the Baekjeong.

## Historical atlas

* Territories of the Khitans from 400 to 1050
* 400
* 500
* 600
* 700
* 800
* 900
* 1025
* Qara Khitai circa 1200
* Mongol Empire circa 1207, showing the locations of the Qara Khitai and Khitans