Nomadic empire
The Xiongnu were a confederation of nomadic tribes from Central Asia with a ruling class of unknown origin and other subjugated tribes. They lived on the Mongolian Plateau between the 3rd century BC and the 460s AD, their territories including modern day Mongolia, southern Siberia, western Manchuria, and the modern Chinese provinces of Inner Mongolia, Gansu, and Xinjiang. The Xiongnu was the first unified empire of nomadic peoples. Relations between early Chinese dynasties and the Xiongnu were complicated and included military conflict, exchanges of tribute and trade, and marriage treaties. When Emperor Qin Shihuang drove them away from the south of the Yellow River, he built the famous Great Wall to prevent the Xiongnu from coming back.
Han–Xiongnu War
However, after the sudden death of Qin Shi Huang, the ensuing political corruption and chaos during the short reign of Qin Er Shi would lead to various anti-Qin rebellions, eventually bring about the collapse of the Qin Dynasty. A massive civil war then erupted between various reinstated states, with Liu Bang eventually victorious to establish the Han Dynasty. During the transitional years between Qin and Han, while the Chinese were mainly focused towards the interior of their nation, the Xiongnu took the opportunity to retake the territory north of the wall. The Xiongnu frequently led incursions to the Han frontier and had considerable political influence over the border regions. 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. His encampment was encircled by the Xiongnu, but Emperor Gaozu escaped after seven days. After realizing that a military solution was not feasible for the time being, Emperor Gaozu sent Liu Jing to negotiate peace with Modu Chanyu. In 198 BC, a marriage alliance was concluded between the Han and the Xiongnu, but this proved far from effective as the incursions in the frontier regions continued.