<P> In the autumn of 1075, Nùng Tông Đán advanced into Song territory in Guangxi while a naval fleet commanded by Lý Thường Kiệt captured Qinzhou and Lianzhou prefectures . Lý Thường Kiệt calmed the apprehensions of the local Chinese populace, claiming that he was simply apprehending a rebel who took refuge in China and that the local Song authorities had refused to cooperate in detaining him . In the early spring of 1076, Thường Kiệt and Nùng Tông Đán defeated the Song militia of Yongzhou, and during a battle at Kunlun Pass, their forces beheaded the Governor - General of Guangnan West Circuit, Zhang Shoujie (d . 1076). After a forty - two - day siege, Yongzhou was breached and razed to the ground . When Song forces attempted to challenge Lý's forces, the latter retreated, with their spoils of war and thousands of prisoners . </P> <P> Lý Thường Kiệt had fought a war with the Cham in 1069, and in 1076 Song called on the Khmer Empire and Champa to go to war again in 1076 . At the same time, the Song commander Guo Kui (1022--1088) led the combined Song force of approximately 100,000 men against Lý . The Song quickly regained Quảng Nguyên prefecture and in the process captured the resistance leader Lưu Ký . By 1077, the Song had destroyed two other Vietnamese armies and marched towards their capital at Thăng Long (modern Hanoi). Song forces halted at the Nhu Nguyệt River (in modern Bắc Ninh Province), where Lý Thường Kiệt had defensive ramparts built on the southern banks . However, Song forces broke through his defense line and their cavalry advanced to within several kilometers of the capital city . The Vietnamese counterattacked and pushed Song forces back across the river while their coastal defenses distracted the Song navy . Lý Thường Kiệt also launched an offensive, but lost two Lý princes in the fighting at Kháo Túc River . According to Chinese sources, "tropical climate and rampant disease" severely weakened Song's military forces while the Lý court feared the result of a prolonged war so close to the capital . In 1078 China defeated Đại Việt and overran several districts that would later make up part of Cao Bằng Province . </P> <P> As a result, Thường Kiệt made peace overtures to the Song; the Song commander Guo Kui agreed to withdraw his troops, but kept five disputed regions of Quảng Nguyên (renamed Shun'anzhou or Thuận Châu), Tư Lang Châu, Môn Châu, Tô Mậu Châu, and Quảng Lăng . These areas now comprise most of modern Vietnam's Cao Bằng Province and Lạng Sơn Province . In 1082, after a long period of mutual isolation, King Lý Nhân Tông of Đại Việt returned Yong, Qin, and Lian prefectures back to Song authorities, along with their prisoners of war, and in return Song relinquished its control of four prefectures and the county of Đại Việt, including the Nùng clan's home of Quảng Nguyên . Further negotiations took place from July 6 to August 8, 1084 and were held at Song's Yongping garrison in southern Guangnan, where Lý's Director of Military Personnel Lê Van Thình (fl. 1075--1096) convinced Song to fix the two countries' borders between Quảng Nguyên and Guihua prefectures . </P> <P> After students passed the often difficult, bureaucratic, and heavily demanding Imperial Exams, as they became officials, they did not always see eye to eye with others that had passed the same examination . Even though they were fully - fledged graduates ready for government service, there was always the factor of competition with other officials . Promotion to a higher post, higher salary, additional honors, and selection for choice assignment responsibilities were often uncertain, as young new officials often needed higher - ranking officials to recommend them for service . Once an official would rise to the upper echelons of central administration based in the capital, they would often compete with others over influence of the emperor's official adoption of state policies . Officials with different opinions on how to approach administrative affairs often sought out other officials for support, leading to pacts of rivaling officials lining up political allies at court to sway the emperor against the faction they disagreed with . </P>

Who brought an end to the song dynasty