The end of the (Eastern) Han dynasty was the period of Chinese history from 189 to 220 CE, roughly coinciding with the tumultuous reign of the Han dynasty's last ruler, Emperor Xian. It was followed by the Three Kingdoms era (220–280 CE). During the end of the Han dynasty, the country was thrown into turmoil by the Yellow Turban Rebellion (184–205). Meanwhile, the Han Empire's institutions were destroyed by the warlord Dong Zhuo and fractured into regional regimes ruled by various warlords, some of whom were nobles and officials of the Han imperial court. The warlord Cao Cao took control of Emperor Xian and his court in 196 and began gradually reunifying the empire. Cao Cao ostensibly operated under Emperor Xian's rule, though in reality the emperor was a hostage.

Cao Cao's efforts to reunify China were rebuffed at the Battle of Red Cliffs in 208–209, when his armies were defeated by the allied forces of Sun Quan and Liu Bei. The Han dynasty formally ended in 220 when Cao Cao's son and heir, Cao Pi, pressured Emperor Xian into abdicating in his favour. Cao Pi became the emperor of a new dynasty, Cao Wei. In response, Liu Bei established the Shu Han dynasty in 221 with himself as its emperor. Sun Quan founded the Eastern Wu dynasty in 222, first adopting the title of king and later declared himself emperor in 229. The period from the end of the Han dynasty in 220 to the reunification of China proper under the Western Jin dynasty in May 280 is known as the Three Kingdoms era in Chinese history.

Collapse of imperial authority (184–191) Yellow Turban Rebellion and decentralisation (184–189)

Towards the end of the reign of Emperor Ling of Han (r. 168–189), many officials in the imperial court foresaw chaos in the political scene as soon as Emperor Ling died. One of those officials, Liu Yan, suggested to Emperor Ling in 188 that the root of the agrarian revolts during that time, including the most serious one, the Yellow Turban Rebellion of 184, was that Inspectors (刺史) lacked substantial administrative powers. Emperor Ling, convinced by Liu Yan, changed the Inspectors' titles to "Governor" (牧) and granted them the authority to levy taxes and command armed forces within the borders. Liu Yan was commissioned as the Governor of Yi Province (covering the Sichuan Basin), while several other important officials also became Governors, including Liu Yu, who was appointed Governor of You Province (covering present-day northern Hebei, Beijing, Tianjin and Liaoning). The increased influence of these provincial governors formed the basis on which later warlords would control large regions of the Han empire.

Imperial power struggle (189) Emperor Ling died in 189 and was succeeded by his 13-year-old son, Liu Bian (born to Empress He), who became known as Emperor Shao. Empress He, now empress dowager, became regent to the young emperor, while her older brother, General-in-Chief He Jin, became the most powerful official in the imperial court. He Jin and Yuan Shao plotted to exterminate all the Ten Attendants, a group of influential eunuch officials in the court, but Empress Dowager He disapproved of their plan. In a fateful move, He Jin summoned Dong Zhuo, a warlord controlling the battle-tested Liang Province (涼州; covering present-day Gansu), to march on the capital Luoyang to pressure Empress Dowager He into eliminating the Ten Attendants. After the eunuchs discovered He Jin's plot, they lured him into the palace and murdered him (22 September 189). In response, Yuan Shao led the imperial guards on an indiscriminate massacre of the palace eunuchs. The surviving eunuchs kidnapped Emperor Shao and his younger brother, the eight-year-old Prince of Chenliu (raised by his grandmother Empress Dowager Dong), and fled north towards the Yellow River, but were finally forced to commit suicide by throwing themselves into the river.

Dong Zhuo arrived on the scene and found Emperor Shao and the Prince of Chenliu. The young emperor appeared nervous and fearful, while the prince remained calm and composed, and gave orders to Dong Zhuo to escort them back to the palace. Dong Zhuo used the opportunity to seize control of state power and bring his army into the capital. Not long later, Dong Zhuo deposed and poisoned Emperor Shao and replaced him with the Prince of Chenliu, who became known as Emperor Xian. Dong Zhuo dominated the imperial court and named himself "Chancellor of State" (相國), a title not held by anyone since the Western Han dynasty statesman Xiao He; Dong Zhuo also granted himself the privilege of attending court without needing to disarm himself or remove his shoes.

Resistance against Dong Zhuo (189–191)

In the spring of 190, several provincial officials and warlords formed a coalition against Dong Zhuo, claiming that he was set on usurping the throne and had effectively kidnapped Emperor Xian. Yuan Shao, Administrator of Bohai (around present-day Cangzhou, Hebei), was nominated to be the leader of the coalition. The coalition's armies were stationed at Henei (河內; in present-day Jiaozuo, Henan) and appeared to be ready to move on the capital Luoyang. However, the coalition was actually rather disorganized, and Yuan Shao did not have effective command over the entire alliance. Besides, the coalition members were also hesitant to directly confront Dong Zhuo and his strong Liang Province army. Still, Dong Zhuo was anxious and chose to move the capital to Chang'an in the west to avoid the coalition. About a month later, Dong Zhuo forced Emperor Xian and the imperial court to move to Chang'an, along with Luoyang's residents, and in the process, he ordered the former capital to be destroyed by fire. During the move, Dong Zhuo remained near Luoyang, ready to resist any coalition attacks on him. In 191, the coalition tried to further de-legitimize Dong Zhuo's position by offering to enthrone Liu Yu, who was eligible to be Emperor since he was a member of the royal clan. Liu Yu remained faithful to Emperor Xian and firmly declined to take the throne. As the coalition members continued to bicker over battle plans, a minor general under Yuan Shu, Sun Jian, took a calculated risk and attacked Dong Zhuo directly near Luoyang. After scoring several victories over Dong Zhuo's forces, Sun Jian eventually forced Dong to retreat to Chang'an, and Luoyang came under the coalition's control.

For the following months until the end of 191, the coalition ceased to take further action against Dong Zhuo and eventually disbanded, with its members returning to their respective bases. Soon, several officials started having thoughts of controlling and ruling over their own territories like kings. The most prominent warlords who emerged at that time included:

Yuan Shao, who seized control of Ji Province (covering present-day central and southern Hebei and northern Henan) from Han Fu in 191 Liu Yan, who controlled Yi Province Liu Biao, who controlled Jing Province (covering present-day Hubei and Hunan) Yuan Shu, Yuan Shao's half-brother (cousin in name), who controlled the area south of the Huai River (covering present-day northern and central Anhui)

However, in addition to these greater warlords, in time the entire Han empire virtually fractured into small blocs, each controlled by a local warlord.

Dong Zhuo's death and continued warfare (192–196)

Dong Zhuo's death and aftermath (192)

After Dong Zhuo withdrew to Chang'an, he maintained an even tighter grip on the government and cruelly dealt with all dissent against him. Interior Minister Wang Yun and a few other officials, including Huang Wan (黃琬), Shisun Rui (士孫瑞), and Yang Zan (楊瓚), plotted to eliminate Dong Zhuo. They eventually persuaded Dong Zhuo's foster son, Lü Bu, to join them. Lü Bu bore a grudge against Dong Zhuo because the latter almost killed him once during a fit of anger, and also because he was afraid that his secret affair with one of Dong Zhuo's maids might be exposed. In May 192, the conspirators, led by Lü Bu and Wang Yun, assassinated Dong Zhuo and slaughtered his clan.

After Dong Zhuo's death, it was believed that the chaos caused by Dong Zhuo's "reign of terror" would subside, and the central government would be restored to its original state. However, although Wang Yun was regarded as a capable minister, he gradually became arrogant and made several key mistakes that would cause his downfall. He failed to maintain good relations with Lü Bu, and strongly refused to grant amnesty to the surviving followers of Dong Zhuo and ordered them to be disbanded. This caused Dong Zhuo's men to fear that they might be massacred. Dong Zhuo's son-in-law, Niu Fu, took control of Dong's forces in Henan and resisted Wang Yun, but was later killed by one of his own subordinates. Niu Fu's subordinates, Li Jue, Guo Si and Fan Chou, wanted to submit to the imperial court, but as they had previously resisted Wang Yun, Wang now rejected their request for amnesty. Li Jue, Guo Si and Fan Chou led their armies to attack Chang'an and took control of the government. Wang Yun was captured and executed along with his family, while Lü Bu was defeated and driven away.

Continued warfare (193–196) After taking control over the imperial court in Chang'an, Li Jue, Guo Si and Fan Chou did as they pleased without showing any regard for the welfare of the state. Concurrently, provincial warlords all over China battled each other to expand their territories or further their personal interests. Some of those warlords were friendly with Li Jue's forces, while others remained hostile to them, even though all of them nominally acknowledged Emperor Xian as the sovereign ruler of China.

In 193, armed conflict broke out between the northern warlords Liu Yu and Gongsun Zan. Liu Yu strongly opposed warfare while Gongsun Zan continuously waged war against Yuan Shao. Liu Yu and Gongsun Zan made accusations against each other in their respective memorials to Emperor Xian. Eventually, Liu Yu was unable to tolerate Gongsun Zan and attacked the latter, but was defeated and killed.

In 195, turmoil ensued in Chang'an when Li Jue and Guo Si killed Fan Chou together, and later turned against each other. Li Jue held Emperor Xian hostage while Guo Si kidnapped the imperial officials, and both sides engaged in battle. Later that year, Li Jue and Guo Si made peace and agreed to allow Emperor Xian to return to the old capital, Luoyang, but later regretted their decision and pursued him. While Li Jue and Guo Si were never able to capture Emperor Xian again, the imperial court was rendered poor and unable to fend for itself. As Luoyang had been previously devastated by fire during Dong Zhuo's time, the city lacked the essentials of life and many officials starved to death or resorted to cannibalism. Around this time, Yuan Shao's advisor Ju Shou suggested that he welcome Emperor Xian to his province so that he could take effective control of the government. However, Yuan's other advisors Guo Tu and Chunyu Qiong opposed Ju Shou's view, claiming that if Yuan brought Emperor Xian to his territory, he would need to yield to the emperor on key decisions and follow proper court protocol. Yuan Shao remained hesitant and did not conclude whether to receive the emperor or not.

Gradual reunification under Cao Cao (196–207) Cao Cao's use of Emperor Xian as titular authority