The Khitan gradually became stronger and developed southward, which was also blocked in this area. In the middle of the Five Dynasties, Shi Jingtang, the general of the later Tang Dynasty, rebelled, defeated the later Tang Dynasty with the support of Ye Ludeguang, Emperor Taizong of Liao Dynasty, and became emperor himself. In order to repay the support of Qidan, Shi Jingtang called Ye Ludeguang his father and ceded sixteen states of Youyun to Qidan.
After the founding of the Northern Song Dynasty, it has been threatened by Liao. In the view of the rulers of the Northern Song Dynasty, only by seizing the sixteen states of Youyun can reunification be achieved. Song Taizu originally wanted to reserve a huge sum of money for redemption from Liao. If he was rejected, he used this huge sum of money for military expenses and captured sixteen states of Youyun. But before it could be implemented, Song Taizu died. In Song Taizong, he launched two wars against Liao, trying to capture sixteen states of Youyun, but both failed. Liao then turned from defending to attacking, and carried out several wars to attack the Song Dynasty, all of which ended in failure.