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.
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.
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.
Wang Mang mobilized 300,000 troops against Xiongnu and forced Goguryeo, Wuhuan and various Western Regions city-states to send conscripts and provisions, which led to the mass defection of these vassal states.
[12] The fortified walls ran from Liaodong to Lintao, thus enclosing the conquered Ordos region,[10] safeguarding the Qin empire against the Xiongnu and other northern nomadic people.
[13] In response, Emperor Gaozu led a Han army against the Xiongnu in 200 BC, pursuing them as far as Pingcheng (present-day Datong, Shanxi) before being ambushed by Modu Chanyu's cavalry.
[24] When the ambush failed, because Junchen Chanyu realized he was about to fall into a trap and fled back north, the peace was broken and the Han court resolved to engage in full-scale war.
[56] During this campaign, Huo Qubing's elite troops had set off from Dai to link up with Lu Bode's forces in Yucheng, after which they advanced further and engaged the Tuqi King of the Left[c] and his army.
[64] The Han empire brought the states of Loulan, Jushi (Turfan), Luntai (Bügür), Dayuan (Ferghana), and Kangju (Soghdiana) into tributary submission between 108 and 101 BC.
[101][102] The first half of the 1st century BC witnessed several succession crises for the Xiongnu leadership, allowing the Han empire to reaffirm its control over the Western Regions.
[103][104] Huduershi Chanyu was succeeded by his son Punu (蒲奴) in 46 AD, thus breaking the late Huhanye's orders that only a Xiongnu ruler's brother was a valid successor.
[112] General Dou Xian marched with his troops in a triumphal progress to the heartland of the Northern Xiongnu's territory and engraved an inscription commemorating the victory on Mount Yanran, before returning to Han.
[5] He sent Deputy Colonel Yan Pan with 2000 light cavalry to strike down the final Xiongnu defenses in the Western Regions, capturing Yiwu and receiving the surrender of Jushi.
[118] However, this never came to pass as Dou Xian dispatched General Geng Kui and Shizi of the Southern Xiongnu with 8,000 light cavalry to attack the Northern Chanyu, encamped at Heyun (河雲), in 90 AD.
[118] In 91 AD, General Geng Kui and Major Ren Shang with a light cavalry of 800 advanced further via the Juyan Gol (Juyansai) into the Altai Mountains, where the Northern Chanyu had encamped.
[124] In a memorandum entitled Guard the Frontiers and Protect the Borders that he presented to the throne in 169 BC, Chao compared the relative strengths of Xiongnu and Han battle tactics.
[125] In regards to the Han armies, Chao deemed the Xiongnu horsemen better prepared for rough terrain due to their better horses, better with horseback archery, and better able to withstand the elements and harsh climates.
[126][127] During Emperor Jing's reign, the Han court initiated breeding programs for military horses and established 36 large government pastures in the border regions, extending from Liaodong to Beidi.
[128] At the start of Emperor Wu's reign, the Han empire had a standing army comprising 400,000 troops, which included 80,000 to 100,000 cavalrymen, essential to the future campaigns against the Xiongnu.
[130] During Emperor Zhao's reign (r. 87–74 BC), the agricultural garrison in Bugur was expanded to accommodate the heavy Han military presence which was the natural result of the empire's westward expansion.
[130] During Emperor Xuan's reign (r. 74–49 BC), the farming soldiers in Kurla were increased to 1500 under Protector-General Zheng Ji's administration in order to support the military expeditions against the Xiongnu in Turfan.
[61][134] They travelled to the territories of Ferghana (Dayuan 大宛), Soghdiana (Kangju 康居), and Bactria (Daxia 大夏), ultimately finding the Yuezhi forces north of the Amu River.
[149] In 88 BC, the Xianling tribe of the Qiang people sent an envoy to the Xiongnu, proposing a joint-attack against the Han in the region as they were discontented that they had lost the fertile lands at Jiuquan and Zhangye.
[149] In 6 BC, Wang Shun (王舜) and Liu Xin noted that the frontier commanderies of Jiuquan, Zhangye, and Dunhuang were established by Emperor Wu to separate the then-powerful Chuoqiang tribe of the Qiang people from the Xiongnu.
[154] This can be exemplified by a situation in 78 BC, when the Xiongnu led a punitive campaign against the Wuhuan, resulting in General Fan Mingyou (范明友) leading a Han army to impede further incursions.
[165] By conquering Loulan and Turfan, the Han empire would gain two critical locations in the Western Regions, achieving direct access to the Wusun in the Ili River valley and Dayuan (Ferghana) between Syr and Amu Darya.
[166] The fact that the forces used comprised solely from the troops of the western states was, as Lewis (2007) remarked, a clear indication of the political influence that the Han empire had over the region.