 Relations between the Liao and the Song were initially peaceful , with the two dynasties exchanging embassies in 974 . Following the collapse of the Tang dynasty , several territories formed small , independent states that were never reunified during the Five Dynasties and Ten Kingdoms period . Additionally , several additional territories that were controlled by military governors during the Tang dynasty had fallen under the control of local warlords following the Tang collapse . Rather than focus on reclaiming land from the Liao dynasty , Zhao Kuangyin , who would take the title Emperor Taizu of Song , focused on reclaiming these smaller break @-@ off territories . He would die in 976 having reestablished control over all but one of these territories , the Northern Han kingdom . Despite the Northern Han 's status as a protectorate of the Liao dynasty , Emperor Taizu of Song launched an invasion of the kingdom in 976 , only months before his death . The Northern Han received assistance from the Liao , and the invasion was repelled . Emperor Taizong of Song , brother of the founding emperor and the second emperor of the Song dynasty , launched a second invasion in 979 . The Northern Han again received Liao assistance , but this invasion was successful ; the Northern Han crumbled , and the Song were able to assume control of the territory . Emperor Taizong of Song immediately followed this victory with an attempted invasion of the sixteen prefectures , but the unrested and undersupplied Song troops were thoroughly routed by the Liao in the Battle of Gaoliang River . 
