The Song–Xia wars () were a series of military conflicts fought by the Northern Song dynasty, Western Xia dynasty, and Liao dynasty from the late 10th century to early 12th century. Although sporadic conflicts would continue, the Northern Song lost their land border with the Western Xia after the Jin–Song Wars and the Jingkang Incident of 1127 which saw the fall of their capital, Kaifeng, to the Jurchen-led Jin dynasty.

Jiqian's rebellion (982-1004)

Song–Xia wars

In 982, the ruler of the Dingnan Jiedushi, Li Jipeng, decided to submit to the Song dynasty and exchange his title for a comfortable existence in Kaifeng. His brother, Li Jiqian, did not agree to this and refused to submit to Song administration. Jiqian led a group of bandit holdouts and resisted Song control. In 984, the Song attacked his camp and captured his mother and wife, but he narrowly escaped. He rebounded from this defeat by capturing Yinzhou the next year. Along with Yinzhou, Jiqian captured large amounts of supply, allowing him to increase his following. In 986, Jiqian submitted to the Khitans and in 989, Jiqian married into Khitan nobility. Jiqian also made symbolic obeisance to the Song, but the Song remained unconvinced of his intentions. Jipeng was sent by the Song to destroy Jiqian, but he was defeated in battle on 6 May 994, and fled back to Xiazhou. Jiqian sent tribute on 9 September as well as his younger brother on 1 October to the Song court. Emperor Taizong of Song was receptive of these gestures, but Jiqian returned to raiding Song territory the next year. In April 996, Taizong sent troops to suppress Jiqian, who raided Lingzhou in May and again in November 997. For a brief period after 998, Jiqian accepted Song suzerainty, until the fall of 1001 when he began raiding again. Jiqian died on 6 January 1004 from an arrow wound. His son and successor, Li Deming, proved to be more amicable towards the Song than his predecessor.

Song–Xia wars

Rise of Yuanhao

Li Deming sent tribute missions to both the Liao dynasty and the Song dynasty. At the same time he expanded Tangut territory to the west. In 1028, he sent his son Li Yuanhao to conquer the Ganzhou Uyghur Kingdom. Two years later the Guiyi Circuit surrendered to the Tanguts. Yuanhao invaded the Qinghai region as well but was repelled by the newly risen Tibetan kingdom of Tsongkha. In 1032, Yuanhao annexed the Tibetan confederation of Xiliangfu, and soon after his father died, leaving him ruler of the Tangut state.

Song–Xia wars

Yuanhao's invasion (1040–1044)

Upon the death of his father, Li Deming, in 1032, Li Yuanhao adopted the Tangut surname of Weiming. He levied all able bodied men between 15 and 60 years of age, providing him with a 150,000 strong army. By 1036, he had annexed both the Ganzhou Uyghur Kingdom and the Guiyi Circuit to his west. In 1038, Yuanhao declared himself emperor of the Great Xia. In response, the Song dynasty cut off border trade and put a bounty on his head.

In the winter of 1039–1040, Yuanhao laid siege to Yanzhou (now Yan'an) with over 100,000 troops. The prefect of Yanzhou, Fan Yong, gave contradictory orders to his military deputy, Liu Ping, making him move his forces (9,000) in random directions until they were defeated by Xia forces (50,000) at Sanchuan Pass. Liu Ping was taken captive. Despite the defenders' mediocre performance, Yuanhao was forced to lift the siege and retreat to a ring of forts overlooking Yanzhou, when heavy winter snows set in.

A Song army of 30,000 returned later that winter under the command of Ren Fu. They were ambushed at Haoshuichuan and annihilated. Despite such victories, Yuanhao failed to make any headway against Song fortifications, garrisoned by 200,000 troops on rotation from the capital, and remained unable to seize any territory.

In 1042, Yuanhao advanced south and surrounded the fort of Dingchuan. The defending commander Ge Huaimin lost his nerve and decided to run, abandoning his troops to be slaughtered. Again, Yuanhao failed to gain significant territory. Half his soldiers had died from attrition and after two years, Western Xia could no longer support his military endeavors. Tangut forces began suffering small defeats, being turned back by Song forces at Weizhou and Linzhou.

The Liao dynasty took advantage of the Song's dire predicaments by increasing annual tribute payments by 100,000 units of silk and silver (each). The Song appealed to the Liao for help, and as a result, Emperor Xingzong of Liao invaded Western Xia with a force of 100,000 in 1044. Liao forces enjoyed an initial victory but failed to take the Xia capital and were brutally mauled by Yuanhao's defenders. According to Song spies, there was a succession of carts bearing Liao dead across the desert.