The Han dynasty (206 BCE – 220 CE), founded by the peasant rebel leader Liu Bang (known posthumously as Emperor Gaozu), was the second imperial dynasty of China. It followed the Qin dynasty (221–206 BCE), which had unified the Warring States of China by conquest. Interrupted briefly by the Xin dynasty (9–23 CE) of Wang Mang, the Han dynasty is divided into two periods: the Western Han (206 BCE – 9 CE) and the Eastern Han (25–220 CE). These appellations are derived from the locations of the capital cities Chang'an and Luoyang, respectively. The third and final capital of the dynasty was Xuchang, where the court moved in 196 CE during a period of political turmoil and civil war.
The Han dynasty ruled in an era of Chinese cultural consolidation, political experimentation, relative economic prosperity and maturity, and great technological advances. There was unprecedented territorial expansion and exploration initiated by struggles with non-Chinese peoples, especially the nomadic Xiongnu of the Eurasian Steppe. The Han emperors were initially forced to acknowledge the rival Xiongnu Chanyus as their equals, yet in reality the Han was an inferior partner in a tributary and royal marriage alliance known as heqin. This agreement was broken when Emperor Wu of Han (r. 141–87 BCE) launched a series of military campaigns which eventually caused the fissure of the Xiongnu Federation and redefined the borders of China. The Han realm was expanded into the Hexi Corridor of modern Gansu province, the Tarim Basin of modern Xinjiang, modern Yunnan and Hainan, modern northern Vietnam, modern North Korea, and southern Outer Mongolia. The Han court established trade and tributary relations with rulers as far west as the Arsacids, to whose court at Ctesiphon in Mesopotamia the Han monarchs sent envoys. Buddhism first entered China during the Han, spread by missionaries from Parthia and the Kushan Empire of northern India and Central Asia.