Tuoba Gui is the grandson of Tuoba Shiyijian, leader of the Tuoba Tribe of Xianbei and acting king. His father Tuoba Gui died before he was born. The Qin Dynasty was destroyed in 376 years ago, and when he was young, he followed his mother He family to attach themselves to the Dugu tribe and the Helan tribe. After the Battle of Feishui in 383, the former Qin Dynasty collapsed. In 386, he summoned his old troops in Niuchuan to take the throne. Soon he was renamed King of Wei and rebuilt the regime with Shengle as the center.
After that, he conquered the Tiefu tribe in the west, defeated Houyan Crown Prince Murong Bao in Shenhebei in 395, and captured the capital of Houyan, Zhongshan, in 397, and captured most of Hebei. In 398, he moved the capital to Pingcheng and became the emperor. He appointed Cui Hong and other Han scholars to formulate official systems and laws, relocated people to cultivate fields, dispersed tribes and settled them in separate territories, promoting the transformation of the Tuoba tribe from a nomadic tribal alliance to a Central Plains-style dynasty.
In his later years, he took cold food powder, became jealous and violent, and repeatedly killed ministers and clan members. Before naming his eldest son Tuoba Si as his heir in 409, he ordered the death of his biological mother Liu Guiren in accordance with the rule of "a son dies before his mother dies." In the same year, his second son Tuoba Shao went to the palace at night to kill his father because his mother, Mrs. He, was convicted and was about to die. Emperor Daowu died at the age of thirty-nine.
Tuoba Gui restored the country as a young man in the chaos of the collapse of the former Qin Dynasty. In more than ten years, he defeated Later Yan and dominated the north. He appointed Han scholars to establish an official system and promote settled farming, which laid the foundation for the unification of the north in the Northern Wei Dynasty and the later Hanization. However, in his later years, he was suspicious and bloodthirsty, and instituted the cruel system of "the son is dearer than the mother," and he eventually died at the hands of his own children. The bloody tradition of the palace continued for several generations.