Military history of the Three Kingdoms
By the time of the Three Kingdoms period the Xiongnu had already ceased to be a major power. Their last stand as a steppe empire was in 89 when Dou Xian led an army of 45,000 and decisively defeated them at the Battle of the Altai Mountains. The Xiongnu Empire was replaced by a loose confederation of disorganized Xianbei tribes, who were nonetheless highly aggressive and proved problematic to their southern neighbors. A southern branch of the Xiongnu split off from their northern neighbors in 50 AD and continued to exist as a Han puppet state in Bing Province. However, in 188 the Xiuchuge clan rebelled against their Chanyu, Qiangqu, for sending troops to aid the Han against the rebels Zhang Ju and Zhang Chun. They replaced Qiangqu with his son Yufuluo, who's hold on power was tenuous, and he was ousted over a marquis of the Xubu clan. When the marquis of Xubu died the next year an elderly king became the nominal head of state without the title of Chanyu and the Southern Xiongnu ceased to exist as a coherent entity. In 216 the Xiongnu of the Ordos were settled but the region remained outside the jurisdiction of Cao Wei's administration.
Han–Xiongnu War
In 25 AD, Liu Xiu was established as Emperor Guangwu, restoring the Han throne after a usurpation by the Han official Wang Mang, thus initiating the Eastern Han period. During his reign, the Han empire began to abandon its offensive strategy against the Xiongnu, which allowed the latter to frequently raid the northern frontier. It resulted in large migrations southwards, which led to the depopulation of the frontier regions. During the Eastern Han period, various nomadic peoples were resettled in these frontier regions, serving the Han empire as cavalry against the Xiongnu. With his primary focus still towards the interior of the empire, Emperor Guangwu declined several requests from the western states to reestablish the office of Protector-General of the Western Regions. Early in Emperor Guangwu's reign, King Kang of Yarkand united neighboring kingdoms to resist the Xiongnu. At the same time, he protected the Han officials and people of the former Protector-General, who were still left behind after Wang Mang's reign. In 61 AD, Yarkand was conquered by Khotan and the western states fell in conflict with each other. Taking this opportunity, the Northern Xiongnu recovered their control over the Western Regions, which threatened the security of the Hexi Corridor. In 73 AD, General Dou Gu was sent on a punitive expedition to the Xiongnu and inflicted them a considerable defeat. Immediately, the fertile lands of Hami (Yiwu) was reoccupied and an agricultural garrison established. The next year (74 AD), he expelled the Xiongnu from Turfan and reoccupied the state. The recovery of Hami and Turfan facilitated the reestablishment of the Protector-General, since these important locations were key points to control the Western Regions.