Zhao Kuangyin, after founding the Song Dynasty in 960, had sought to recapture the sixteen prefectures, a region in northern China stretching from present-day Beijing westward to Datong, which the Khitan Liao Dynasty had acquired in 936.
In most areas, it is approximately seventy to one hundred miles in width, covering a strategic area of modern Hebei and Shanxi that has become the focus of contention between the Khitan Liao Dynasty to the north and the Shatuo Turk Later Jin Dynasty (which had ceded the prefectures to the Liao in 937) and the Han Chinese Later Zhou Dynasty and the Song Dynasty.
Zhao Kuangyin’s brother and successor, Emperor Taizong, personally leads a military expedition that reaches Youzhou in 979, and lays siege to the city.
The city's walls, some 16 km in circumference, withstand the siege for three months.
Defenders are bolstered by Khitan reinforcements who are able burrow under the Song siege and into the city itself.
A large Liao reinforcement arrives and defeats the Song Army north of Youzhou, just west of Xizhimen, in present-day Beijing.
More than one hundred and sixty years after this defeat, the Song will briefly take control of modern day Beijing in 1123 when the Song-Jin Alliance defeats the Liao and the city is ceded by the Jin Dynasty to the Song.
However, two years later, the Jin will invade the Song lands and retake Yanshan.