Cao Cao gathered an army in 184 to fight against the Yellow Scarves rebellion. After the Dong Zhuo had seized the Emperor Liu Bian in 189 and deposed him in favour of his brother Liu Xie (Emperor Xian), a coalition of local warlords all over the country arose against Dong. It was called by Cao Cao and led by Yuan Shao, and many powerful warriors joined it. After Dong Zhuo's death through the hands of his foster son Lü Bu, Emperor Xian was controlled by Dong's associates. He fled to Chang'an (the old capital) in 195 but almost starved to death. Cao Cao saved him in 196 and brought him to his own place at Xuchang.
With the emperor under his control, Cao Cao managed to slay most of the minor warlords in Northern China and was even able to defeat Lü Bu and the powerful Yuan Shao at Guandu in 200. He tried to conquer the south, too, but Liu Bei and Sun Quan opposed him and defeated his forces in the Battle at Red Cliffs. Cao Cao led several campaigns against the south, but with fairly low success. Also, he managed to get the famous general Guan Yu killed by Sun Quan's general Lü Meng.
Cao Cao died in 220, and his son Cao Pi followed him in control of the emperor. He eventually deposed him the same year and became Emperor Wen of Wei, making his father posthumously Emperor Wu of Wei.