Emperor Daowu of Northern Wei () (4 August 371 – 6 November 409), personal name Tuoba Gui (), né Tuoba Shegui (), was the founding emperor of the Northern Wei. He was the grandson of the last prince of Dai, Tuoba Shiyijian. After the fall of the Dai state to Former Qin in 376, he was presumed to be the eventual successor to the Dai throne. After Former Qin fell into disarray in 383 following its defeat by Jin forces at the Battle of Fei River, Tuoba Gui took the opportunity to reestablish Dai in 386. He soon changed the state's name to Wei and declared himself a prince. He was initially a vassal of Later Yan, but after defeating Later Yan emperor Murong Bao in 397 and seizing most of Later Yan's territory, he claimed the imperial title in 398.

Emperor Daowu was commonly regarded as a brilliant general, but cruel and arbitrary in his rule, particularly toward the end of his reign. In 409, as he considered killing his concubine Consort Helan, his son Tuoba Shao () the Prince of Qinghe, by Consort Helan, killed him, but was soon defeated by the crown prince Tuoba Si, who then took the throne as Emperor Mingyuan.

Emperor Daowu of Northern Wei

Life before founding of Northern Wei

Birth and childhood

According to official accounts, Tuoba Gui was born in 371, after his father Tuoba Shi (), the son and heir apparent to Tuoba Shiyijian the Prince of Dai, died earlier in the year from an injury he suffered while protecting Tuoba Shiyijian from an assassination attempt by the general Baba Jin (). His mother was Tuoba Shi's wife Heiress Apparent Helan, the daughter of the powerful tribal chief and Dai vassal Helian Yegan (). Tuoba Shiyijian, while mourning his son's death, was very pleased by the grandson's birth, and he declared a general pardon in his state and named the child Tuoba Shegui. (Other than the reference to the naming at birth, however, the name "Shegui" was scantily mentioned in historical accounts of the rest of his life, and presumably was shortened to "Gui" for simplicity.)

Emperor Daowu of Northern Wei

Around New Years 377, Former Qin launched a major attack against Dai. Tuoba Shiyijian temporarily fled his capital Yunzhong (雲中, in modern Hohhot, Inner Mongolia), but returned after Former Qin retreated. After his return, however, his nephew Tuoba Jin () convinced his oldest surviving son Tuoba Shijun () that Tuoba Shiyijian was considering naming one of the sons of his wife Princess Murong (a Former Yan princess) as heir and killing him. In response, Tuoba Shijun ambushed his father and brothers and killed them. This led to a collapse of Dai forces, and Former Qin forces occupied Yunzhong without a fight.

Emperor Daowu of Northern Wei

In the disturbance, Tuoba Gui's mother Lady Helan initially fled to her brother Helan Na (), who had taken over as tribal chief after Helan Yegan's death. Later, the Former Qin emperor Fu Jiān considered taking Tuoba Gui to the Former Qin capital Chang'an, but Tuoba Shiyijian's secretary Yan Feng () convinced Fu Jiān to instead allow Tuoba Gui to remain in Dai lands to be groomed as the eventual Dai prince, arguing that this would be the best way to maintain the tribes' allegiance to Former Qin. Meanwhile, Fu Jiān divided the Dai tribes into two groups, commanded by the Xiongnu chiefs Liu Kuren () and Liu Weichen (). Tuoba Gui, along with his mother, went to live with Liu Kuren, who honored the child as a prince.

Adolescence

Little is known about Tuoba Gui's life until 385, by which time Former Qin, which had come close to uniting all of China, had fallen into great disturbance in light of rebellions throughout the empire. In 384, Liu Kuren had attempted to aid Fu Jiān's son Fu Pi, who was then under siege by Murong Chui, the founder of Later Yan, but was assassinated by Muyu Chang (), the son of a Later Yan noble; he was succeeded by his brother Liu Toujuan (). In 385, however, Liu Toujuan was assassinated by Liu Kuren's son Liu Xian (), who took over as chief and viewed Tuoba Gui, now 14, as a threat. However, his subordinates Balie Liujuan () and Qiumuling Chong () found out, and at Balie's instruction Qiumuling escorted Tuoba Gui to his uncle Helan Na, who put Tuoba Gui under his protection. In 386, at the urging of previous Dai officials, Helan Na supported Tuoba Gui in reassuming the title of Prince of Dai.