Zhao Guangyi, posthumously known as Emperor Taizong, succeeded his brother Song Taizu in 976 AD. He was a determined ruler who completed the conquest of the remaining independent kingdoms, most notably the Northern Han in 979, finally ending the fragmentation of the Five Dynasties and Ten Kingdoms period.
Immediately following his victory over Northern Han, he launched an ambitious but poorly prepared campaign to retake the Sixteen Prefectures of Yanyun from the Khitan Liao Empire. This ended in a disastrous defeat at the Battle of Gaoliang River, where Taizong himself was wounded and narrowly escaped on a donkey cart. A second attempt in 986, the Yongxi Campaign, also ended in failure.
Despite his military setbacks against the Liao, Taizong was a master of civil administration. He greatly expanded the Imperial Examination system, shifting power from hereditary military families to a scholar-official bureaucracy, a move that would define the character of the Song Dynasty for centuries.