Emperor Daowu of Northern Wei ((北)魏道武帝) (371–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, and after the fall of the Dai state to Former Qin in 376 had been 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, but soon changing the state's name to Wei and declared himself a prince. He was initially a vassal of Later Yan. However, after he defeated the Later Yan emperor Murong Bao in 397 and seized most of Later Yan's territory, he claimed 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.
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, had died earlier in the year from an injury suffered when 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.)