Securing the emperor
Through short-term and regional-scale wars, Cao Cao continued to expand his power.
In 196, Cao Cao found Emperor Xian and convinced him to move the capital to Xuchang as per the suggestion from Xun Yu and other advisors (as Luoyang was ruined by war and Chang'an was not under Cao Cao's military control), and he was proclaimed Chancellor. Cao Cao was then instated as the General-in-Chief (大將軍) and Marquis of Wuping (武平侯), though both titles had little practical implication. While some viewed the Emperor as a puppet ruler under Cao Cao's power, Cao Cao himself adhered to a strict personal rule to his death that he would not usurp the throne. Later in his life, when he was approached by his advisors to take over the Han Dynasty and start a new rule, he replied, "If heaven bestows such fate on me, let me be the King Wen of Zhou."
Uniting the North
In 200, Yuan Shao amassed more than 100,000 troops and marched southwards on Xuchang in the name of rescuing the emperor. Cao Cao gathered 20,000 men in Guandu, a strategic point on the shore of the Yellow River. The two armies came to a standstill as neither side was able to make much progress. Cao Cao's lack of men did not allow him to make significant attacks, and the pride of Yuan Shao forced him to target Cao Cao's force head-on. Despite his overwhelming advantage in terms of manpower Yuan Shao was unable to make full use of his resources because of his indecisive leadership and Cao Cao's location.
Besides the middle battleground of Guandu, two lines of battle were present. The eastern line with Yuan Tan of Yuan Shao's army versus Zang Ba of Cao Cao's army was a one-sided battle in favor of Cao Cao, as Yuan Tan's own questionable leadership was no match for Zang Ba's local knowledge of the landscape and hit-and-run tactics. To the western side, Yuan Shao's cousin, Gao Gan, performed much better against Cao Cao's army and forced several reinforcements from Cao Cao's main camp to maintain the western battle. Liu Bei, who was at the time a guest in Yuan Shao's army, also suggested to induce uprising in the back of Cao Cao's lands as there were many connections to the Yuan family and their subordinates. The tactic was successful at first, but quickly countered by Man Chong's diplomatic skill. Man Chong had been placed as an official there for this specific reason, as Cao Cao had foreseen the situation prior to the battle.
Finally, with the help of a defector from Yuan Shao's army, Xu You, who informed Cao Cao of the location of Yuan Shao's army supply, Cao Cao broke the standstill and sent a special task force to burn all the supplies of Yuan Shao's army and won a decisive and seemingly impossible victory. Yuan Shao fell ill and died shortly after returning from the defeat, leaving his legacy to two of his sons – the eldest son, Yuan Tan and the youngest son, Yuan Shang. As he had designated the youngest son, Yuan Shang, as his successor, rather than the eldest as tradition dictated, the two brothers consistently feuded against each other, as they fought Cao Cao. Because of their internal divisions, Cao Cao was easily able to defeat them by using their differences to his advantage. Henceforth Cao Cao assumed effective rule over all of northern China. He sent armies further out and extended his control past the Great Wall into northern Korea, and southward to the Han River.
However, Cao Cao's attempt to extend his domination south of the Yangtze River was unsuccessful. He received an initial great success when Liu Biao, ruler of Jing province, died, and his successor, Liu Cong surrendered to Cao Cao without resistance. Delighted by this outcome, he pressed on despite the objections by his military advisors and hoped the same would happen again. His forces were then defeated by the first coalition of his archrivals Liu Bei and Sun Quan (who later founded the states of Shu Han and Eastern Wu respectively) at the Red Cliffs in 208.
To maintain a good relationship with Yuan Shao, who had become the most powerful warlord in China when he united the northern four provinces, Cao Cao lobbied to have Yuan Shao named Minister of Works (司空). This however had the exact opposite effect, as Yuan Shao believed that Cao Cao was trying to humiliate him after having the Emperor's support, since Minister of Works technically ranked lower than General-in-Chief, and thus Yuan Shao refused to accept the title. To pacify Yuan Shao, Cao Cao offered his own position, General-in-Chief, to Yuan Shao, while taking Minister of Works role himself. While this temporarily resolved the conflict, it was nevertheless the catalyst for the Battle of Guandu later.