Toward the end of the Han Dynasty, Yellow Turban Rebellion erupted in Hebei in AD 184 and briefly seized You Prefecture's administrative seat at Ji. The court relied on regional militaries to put down the rebellion and You Prefecture was controlled successively by warlords Liu Yu, Gongsun Zan, Yuan Shao, Yuan Xi and Cao Cao. In 192, Liu Yu was overthrown by his subordinate Gongsun Zan. Two years later, Gongsun Zan was driven out of Ji by Yuan Shao with the help of Wuhuan and Xianbei allies from the steppes. After Yuan Shao lost supremacy of North China to Cao Cao in the Battle of Guandu in AD 200, his son Yuan Xi held You Prefecture until 204 before fleeing to the Wuhuan. Cao Cao eventually defeated the Wuhuan in AD 207 and pacified North China.