Tuoba Gui was born into the royal Tuoba clan of the Xianbei tribe during the chaotic Sixteen Kingdoms period. After the fall of the state of Dai to Former Qin, his clan was scattered, but following the devastating defeat of Former Qin at the Battle of Fei River in 383, Tuoba Gui seized the opportunity to declare independence.
In 386 AD, he founded the Northern Wei dynasty and embarked on an ambitious path of rapid expansion. Initially struggling against powerful northern rivals, his brilliant military leadership and administrative reforms transformed Northern Wei into a formidable state. In 395 AD, he inflicted a crushing and decisive defeat upon the massive army of Later Yan at the momentous Battle of Canhe Slope.
This legendary victory fundamentally altered the balance of power in Northern China forever. Tuoba Gui established his capital at Pingcheng (present-day Datong) and assumed the imperial title as Emperor Daowu. He introduced crucial policies that encouraged agriculture and gradually integrated Han Chinese systems with nomadic traditions, a crucial foundation for his grandson Tuoba Tao's sweeping unification of the north.