The Han–Xiongnu War, also known as the Sino–Xiongnu War, was a series of military conflicts fought over two centuries (from 133 BC to 89 AD) between the Chinese Han Empire and the nomadic Xiongnu confederation, although extended conflicts can be traced back as early as 200 BC and ahead as late as 188 AD.
The Chinese civilization initially clashed with nomadic tribes that would later become the Xiongnu confederation during the Warring States period, and various northern states built elongated fortifications (which later became the Great Wall) to defend against raids from the Mongolian Plateau. The unified Qin dynasty, who conquered all other states under the First Emperor, dispatched General Meng Tian in 215 BC in a successful campaign to expel the Xiongnu from the Ordos region. However, the subsequent civil wars following Qin dynasty's collapse gave the Xiongnu tribes, who were then unified into a large confederacy under Modu Chanyu, the opportunity to reinvade the Ordos region. After the Western Han dynasty was established in 202 BC, Emperor Gao tried to fight off Xiongnu invasions but had himself trapped in an ambush during the Battle of Baideng, and a truce was negotiated. Decades of de jure "peace" then ensued then followed with the Chinese gifting "marriage alliance" to appease the Xiongnu, who still raided Chinese borderlands routinely.
However, starting from the reign of the seventh Han ruler, Emperor Wu, the Han Empire began to change from a relatively passive foreign policy to a proactively offensive strategy seeking to permanently remove the northern threat. The tension fully escalated in 133 BC when the Han army unsuccessfully tried to ambush Xiongnu raiders at Mayi, and retaliatory raids intensified. Emperor Wu then started deploying newer generations of military commanders and launched several expeditions to control the Ordos Loop, Hexi Corridor and Western Regions, eventually pushing the Xiongnu north beyond the Gobi Desert with a decisive campaign in 119 BC. After the death of Emperor Wu in 87 BC, the war winded down to mostly smaller border conflicts, although Emperor Xuan and Yuan had each sanctioned major offensives against the Xiongnu during their reigns. The overall strategic Han successes against the Xiongnu allowed the Chinese to project their influence deeply into Central Asia, which eventually led to the establishment of a regional protectorate in 60 BC. For the Xiongnu, the situation deteriorated with each setback, leading to erosion of the chanyu's prestige and dominance, and the subsequent internal power struggles further weakened the confederation, fracturing it into various self-ruling factions. Han Empire then began adhere to a divide and rule strategy, using marriage alliances (such as that of Wang Zhaojun to Huhanye) to recruit some against others.