Sixteen Prefectures

The Sixteen Prefectures () comprise a historical region in northern China along the Great Wall in present-day Beijing, Tianjin, and northern Hebei and Shanxi.
Name.
It is more specifically called the Sixteen Prefectures of Yan and Yun or the Sixteen Prefectures of You and Ji ().
Overview.
After the Tang dynasty collapsed, they became a site of contention between various ethnicities of North China, including Han, Khitan, Jurchen, Mongol, and Manchu. 
In 938 they were ceded by Shi Jingtang of the Shatuo-led Later Jin to the Khitan-led Liao dynasty. The northern territories were then the site of contention between the subsequent Later Zhou, Song dynasty, and Liao dynasty. 
In 1120s, two principal cities, Youzhou (also called Yanzhou, modern Beijing) and Yunzhou (modern Datong) were taken away from the Liao when the Jurchen-led Jin dynasty conquered the region. 
In 1123, the Jin ceded most of the territories except Yunzhou to the Song, but retook them in 1125. The loss of the Sixteen Prefectures exposed the plains of central China to the Mongol Empire in the 13th century. The Mongols would later conquer the Jin and then unify all of China proper, establishing the Yuan dynasty.
In 1368, Hongwu Emperor of the Ming dynasty ordered Xu Da and Chang Yuchun to call for the restoration of Han rule. They sent a Northern Expedition to Zhongyuan, overthrowing the Yuan and establishing the Ming. The Sixteen Prefectures were then restored to Han rule.
Tang dynasty political geography.
The Sixteen Prefectures were administrative units established during the Tang dynasty. Under the Tang, each prefecture or "zhou" was a unit of administration larger than a county but smaller than a province. The Sixteen Prefectures stretched from Ji County in modern-day Tianjin Municipality to Datong in Shanxi Province, extending contiguously along the mountains that divide the agrarian plains of central China from the pastoralist steppes to the north. Several dynasties including the Qin and the Northern Dynasties before the Tang built the Great Wall along these mountains. Seven of the Sixteen Prefectures were located inside (south) of the Inner Great Wall. The other eleven were located in between the Inner and Outer Great Walls. The Tang did not build Great Walls but used frontier military commanders to guard against the northern tribes. The Fanyang or Youzhou-Jizhou Commandery, based in modern-day Beijing commanded 11 of the Sixteen Prefectures. The other seven were commanded by the Hedong Commandery based in Yunzhou, modern Datong.
The historian Frederick W. Mote writes that there were actually 19 prefectures but does not specify them. Chinese historians do not consider Yíngzhou (营州; modern Qian'an, Hebei) and Pingzhou (平州; modern Lulong, Hebei) to be part of the Sixteen Prefectures because they had already been occupied by the Liao dynasty during the Later Tang, prior to Shi Jingtang’s cession. Yizhou (易州; modern Yi County, Hebei), which fell to the Liao after the cession, is also excluded from the count of 16. The Liao created two new prefectures, Jingzhou (景州 modern Zunhua, Hebei) from Jizhou and Luanzhou (滦州; Luan County, Hebei) from Pingzhou, which have not been included in the original 16.
Five Dynasties Ten Kingdoms period.
The year 907 and subsequent collapse of the Tang dynasty was a turning point in East Asian history. On that year the pastoral and nomadic people known as the Khitan crowned Yelü Abaoji (Emperor Taizu of Liao) as their new Great Khan, the first from the Yelü tribe after some two centuries of leadership by the Yaolian clan. Abaoji coveted the plains of North China, a rich source of plunder that was guarded by a line of passes and fortifications stretching from mountainous northern Shanxi to the Bo Sea. In 905 Abaoji had already started to intervene in northern China by leading a massive army to Datong in Shanxi to swear brotherhood with Li Keyong who nominally served the severely weakened Tang dynasty as Jiedushi of Shanxi on the westernmost point of the defense line.
The rise of Khitan power under Abaoji occurred just as China was falling into turmoil. The fall of the Tang dynasty in 907 led to power struggles among rival warlords and to the creation of a number of short-lived polities known as the Five Dynasties. The first of these dynasties was founded by Zhu Wen, another Jiedushi, who declared himself emperor of the Later Liang in 907 after deposing the last Tang emperor. In 923 his dynasty was overthrown by Li Keyong's son, Li Cunxu, who then proclaimed the Later Tang.
The Sixteen Prefectures passed into Liao hands in 938, when the Liao dynasty supported Shi Jingtang, another military governor of Shanxi, in his revolt against the Later Tang. Confident in his own military strength, the Liao emperor, Abaoji's second son Yelü Deguang (Emperor Taizong of Liao), convinced Shi to found a new dynasty (the Later Jin), but also to cede a large band of territory to the Liao that represented the entire northern China defense line. The Liao dynasty now possessed all the passes and fortifications that controlled access to the northern China plains.
Liao rule.
The Khitan-led Liao dynasty kept using Chinese administrative forms to administer the counties and prefectures they had captured. They named Datong (on the western end of the Sixteen Prefectures) their Western Capital, and in 938 built a new fortified city at Youzhou (near modern-day Beijing), which they turned into their Southern Capital. Under Liao rule, the Sixteen Prefectures thus represented two of the Liao dynasty's five divisions. Both sections were part of the Southern Chancellery, one of two broader divisions the Liao empire had been divided into. The Sixteen Prefectures had become the springboard from which the Liao dynasty would exert its influence on northern China.
Shi Jingtang, the Later Jin emperor who had ceded the Sixteen Prefectures to the Liao dynasty in 937, died in 942. He had been a staunch ally (some say a puppet) of the Khitan, but his successor Shi Chonggui refused to recognize the Emperor Taizong of Liao as his superior. After a year of tense diplomatic exchanges, in 943 the Liao dynasty finally resolved to punish Shi for his insubordination. For two years the engagements were indecisive, until in 945, the Emperor Taizong of Liao, who was leading his troops in battle, was almost killed in a rout of his forces in southern Hebei; he had to flee the battlefield on a camel. The following year, however, the Liao emperor launched a new campaign from his Southern Capital (within the Sixteen prefectures), triggering the collapse of the Later Jin. Having seized the Later Jin capital of Kaifeng in early 947, later that year he declared the name of his dynasty as "Great Liao" (大遼) and proclaimed himself Emperor of China. The Emperor Taizong of Liao quickly became disillusioned with governing so many sedentary people who resented Liao rule, and decided to retreat back to his Southern Capital. Heavy resistance on the retreat route and Taizong's death in 947 provoked a succession crisis in the Liao government, and an opportunity for a new dynasty in northern China.
Still, the territory remained in Liao hands. However, by 960, the Song dynasty had ended the turmoil that northern China had endured since 907, and by 979, they had essentially unified China proper, with the exception of the Sixteen Prefectures.
Liao-Song contention.
The Liao and Song were actually developing reasonably amicable relations in the 960s into the mid-970s, during the reign of the Emperor Taizu of Song. The Song dynasty was still focusing on the south where it was attempting to reunite the bulk of China proper. However, despite the exchange of embassies in 974 and the growth of profitable trade between the two, there were still two fatal flaws to the relationship. One concerned continued support for the Northern Han. The other was the Song dynasty's refusal to accept continued Liao possession of the Sixteen Prefectures.
When the Song were successful in finally incorporating the Northern Han in 979, the Song decided to launch an offensive against the Liao in the Sixteen Prefectures. Emperor Taizong of Song led his weary and ill-supplied troops from toward the Liao Southern Capital (present-day Beijing). The Liao boundary was reached in May and they initially encountered little resistance. By July 20, they had attacked the Southern Capital. Ten days later, the first contingent of Liao cavalry arrived. The ensuing Battle of Gaoliang River on August 1 near the Southern Capital resulted in a complete rout of Song forces, who had to retreat back to Kaifeng. The Sixteen Prefectures would remain in Liao hands.
After Emperor Jingzong of Liao died, Empress Dowager Chengtian took power at age 30 in 982, serving as a regent for her 11-year-old son Emperor Shengzong of Liao and led military campaigns along with her son until her death. The Song dynasty once again tried to attack in 986, to take advantage of Shengzong's youth. They sent forces against the territory on three fronts, but the Liao scored decisive victories over all three Song forces. Empress Dowager Chengtian personally led the Liao army in campaigns against the Song during their invasion of Liao in 986 and defeated them in battle, fighting the retreating Chinese army. She then ordered the castration of around 100 ethnic Chinese boys she had captured in China, supplementing the Khitan's supply of eunuchs to serve at her court, among them was Wang Ji'en. The boys were all under ten years old and were selected for their good looks. The "History of Liao" (遼史) described and praised Empress Chengtian's capture and mass castration of Chinese boys in a biography on the eunuch Wang Ji'en. The fifteen-year-old Emperor Shengzong led the Liao's decisive victory at the Battle of Qigou Pass.
Ethnic Han elites held a prominent position in the Liao state alongside Khitan elites. One of them was a lineage with the surname Hán (韓). The Khitan had abducted the Hán clan from Jizhou and despite being ethnic Han, they were thoroughly Kitanized culturally and linguistically and served the Liao loyally in military and political positions along with several other ethnic Han elite families who were Kitanized. The loyalty of the Han population of the Liao to the Liao rulers frustrated the Song dynasty ruled by ethnic Han. Khitan women from the imperial consort clan were given to the men of the Hán family for marriage. One member of this lineage was Han Derang (韓德讓), who was close to the Liao imperial family and whose paternal ancestors served the Liao dynasty from the time of Abaoji's reign. Han Derang was the ethnic Han minister who had a love affair with the Empress Dowager Chengtian, and Chengtian was rumoured to have a son with him.
Through the 990s, relations between the Song and Liao steadily worsened. Beginning in 999, the Liao would use the Sixteen Prefectures as the launching pad for repeated but indecisive attacks on the Song. Then, in 1004, the Emperor Shengzong of Liao launched another major campaign against the Song. The Chanyuan Treaty signed in early 1005 resulted in annual tribute paid to the Liao dynasty by the Song dynasty.
This treaty was the guide by which relations between the two dynasties would progress until the fall of the Liao dynasty. The Sixteen Prefectures would remain in their possession until that time.
Jin-Song contention.
When the Song dynasty reclaimed the Sixteen Prefectures, they were "fiercely resisted" by the Han population there who had previously been under Liao rule, while when the Jin dynasty invaded that area, the Han population did not oppose them at all and handed over the Southern Capital (present-day Beijing, then known as Yanjing) to them. The Jin dynasty were supported by the anti-Song, Beijing-based noble Han clans. Ethnic Han who worked for the Liao were viewed as hostile enemies by the Song dynasty. Ethnic Han from the Song dynasty also defected to the Jin.