The Han dynasty was an imperial dynasty of China which ruled from 202 BC to 9 AD and from 25 AD to 220 AD, with Chang'an, Luoyang, and Xuchang serving as its capitals. Following the collapse of the Qin dynasty due to internal strife, the rebel leader Liu Bang established the Han dynasty, defeating his rival Xiang Yu of Chu and the other 17 kingdoms which had emerged.
Liu Bang ruled from Chang'an, and his descendants, the emperors, were at the pinnacle of Han society. The emperors shared power with the nobility and appointed ministers from the scholarly gentry class, and it was divided into commanderies. Following the Rebellion of the Seven States in 154 BC, the semi-autonomous kingdoms within the Han were stripped of autonomy.
During the 2nd century BC, the dynasty embraced Confucianism in education and court politics, and the Han also ushered in an era of economic prosperity, pioneered papermaking, the nautical steering ship rudder, the use of negative numbers in mathematics, the raised-relief map, an armillary sphere for astronomy, and a seismometer.
In 200 BC, the Xiongnu forced the Han to become a vassal for several decades, but Emperor Wu of Han (r. 141-87 BC) launched several campaigns which turned the tables and forced the Xiongnu to become vassals of the Han. Han control was extended into the Tarim Basin of Central Asia, leading to the establishment of the Silk Road.
Nanyue was annexed in 111 BC, followed by Dian in 109 BC, and the Xuantu and Lelang Commanderies were established in Korea in 108 BC. From 9 to 23 AD, the Han was overthrown and replaced by Wang Mang's short-lived Xin dynasty, separating the Western Han and Later Han periods.
After 92 AD, the empire entered into a decline due to power struggles between eunuchs, empresses, and court officials, and the rise of Taoist religious societies instigated the Yellow Turban Rebellion in 184 and the Way of the Five Pecks of Rice from 191 to 215. In 189, military officers massacred the Ten Eunuchs, allowing for the aristocrats and military men of the Han to become warlords and divide the empire. The deeply-fragmented Han was formally abolished in 220 when Cao Pi deposed Emperor Xian of Han and proclaimed himself Emperor of Cao Wei.