The Han dynasty (201 BCE – 220 CE) was the second imperial dynasty of China. It followed the Qin dynasty, which had unified the Warring States of China by conquest. It was founded by Liu Bang (Emperor Gaozu). The dynasty is divided into two periods: the Western Han (202 BCE – 9 CE) and the Eastern Han (25–220 CE), interrupted briefly by the Xin dynasty (9–23 CE) of Wang Mang. 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.