Yuan Baoju was born in 507. His father Yuan Yu the Prince of Jingzhao was the son of and a younger brother of the then-reigning . His mother was recorded as Yuan Yu's concubine Lady Yang. He had three other brothers, at least one of whom, Yuan Baoyue , was older, and born of Ladi Li.
Yuan Yu favored Lady Li and had no liking for his wife, Princess Yu -- a sister to Emperor Xuanwu's wife . Empress Yu, because of this, once summoned Lady Li to the palace, beat her severely, and then forced her to become a Buddhist nun. Only after the intercession of Empress Yu's father Yu Jing was Lady Li returned to Yuan Yu. Meanwhile, in 508, Yuan Yu himself was punished by Emperor Xuanwu for corruption -- he was caned 50 times and demoted to the governorship of Ji Province . In anger, he rebelled at the capital of Ji Province, Xindu , alleging falsely that Emperor Xuanwu's uncle Gao Zhao had murdered the emperor and declaring himself emperor. Yuan Yu's rebellion was soon defeated by the general Li Ping , and during his being delivered to the capital Luoyang, Gao had him killed. At that time, Lady Li was pregnant, and she was permitted to give birth and then was executed. Emperor Xuanwu did not execute any of Yuan Yu's sons, but had them, including Yuan Baoju, put under arrest at Zongzheng Temple . Assuming that Lady Li and Lady Yang were in fact the same person, this also meant that Yuan Baoju grew up without either parent. He and his brothers remained at Zongzheng Temple and were released only after Emperor Xuanwu's death in 515. During the reign of Emperor Xuanwu's son , Emperor Xiaoming's mother posthumously recreated Yuan Yu the Prince of Lintao, and Yuan Baoju and his brothers then observed a mourning period for their parents. Yuan Baoyue inherited the title, but Yuan Baoju did not possess any titles at the moment, although he was made a general. Despite Empress Dowager Hu's rehabiilitation of Yuan Yu, however, Yuan Baoju was not impressed at her toleration of corruption, particularly by her lovers, and he secretly plotted with Emperor Xiaoming to have her lovers killed. When this plot was discovered, he was stripped of the office he held. In 525, he married his wife , the daughter of a moderately prominent aristocratic family. In 528, Emperor Xiaoming created him the Marquess of Shao County, and in 530, created him the Prince of Nanyang.
In 532, after several years of civil war, the victorious general Gao Huan made Yuan Baoju's cousin the Prince of Pingyang emperor . Emperor Xiaowu was not happy about Gao's hold on the military, and he entered into alliances with the independent generals Yuwen Tai and Heba Sheng , seeking to resist Gao's control. Yuan Baoju served in Emperor Xiaowu's administration as a general. In 534, Emperor Xiaowu planned to act against Gao, but Gao discovered his plan and instead marched on Luoyang. Emperor Xiaowu decided to flee to Yuwen's territory, and Yuan Baoju accompanied Emperor Xiaowu in doing so, arriving at Chang'an in late 534. Also accompanying Emperor Xiaowu was Yuan Baoju's sister Yuan Mingyue -- who was in an incestuous relationship with Emperor Xiaowu. Yuwen did not tolerate Emperor Xiaowu's incestuous relationships with Yuan Mingyue and two other cousins, and eventually he had Yuan Mingyue killed. Emperor Xiaowu became angry, and his relationship with Yuwen deteriorated. Around the new year 535, Yuwen poisoned him to death.
Initially, Yuwen was poised to make Emperor Xiaowu's nephew Yuan Zan the Prince of Guangping the new emperor. However, under suggestion of Yuan Shun the Prince of Puyang, who argued that Yuan Zan was too young, Yuwen changed his mind and made Yuan Baoju, then 27, emperor instead . As Gao had earlier declared , the son of Yuan Baoju's cousin Yuan Dan the Prince of Qinghe, emperor, Gao's territory became known as Eastern Wei, with Yuan Shanjian as emperor, and Yuwen's territory became known as Western Wei, with Emperor Wen as emperor.
Yuwen Tai publicly deferred to Emperor Wen on most matters, but Yuwen held actual power, with Emperor Wen not being able to exercise much independent authority. Throughout the early years of his reign, there were serious doubts as to whether Western Wei would survive, as Eastern Wei was then the much stronger state, and Gao Huan made repeated attempts to conquer Western Wei. However, with Yuwen and other generals capably defending the territory, Western Wei was able to withstand Gao's assaults.
In 535, Emperor Wen posthumously honored his father Yuan Yu as Emperor Wenjing, and he posthumously honored his mother Lady Yang as empress. He created his wife Princess Yifu empress, and her son crown prince. His marriage with Empress Yifu was said to be a happy one, as she was virtuous and beautiful, and Emperor Wen respected her greatly. She bore him 12 children, although only Yuan Qin and Yuan Wu the Prince of Wudu survived infancy.
In 538, with Western Wei under the threat of attack by Rouran, Yuwen first tried to alleviate the situation by marrying a daughter of a member of the imperial clan to Yujiulü Tahan , the brother of Rouran's Chiliantoubingdoufa Khan Yujiulü Anagui, but then, believing that to be insufficient, he asked Emperor Wen to divorce Empress Yifu and marry . Emperor Wen agreed, and divorced Empress Yifu, making her a Buddhist nun. He then married Yujiulü Anagui's daughter and created her empress. For a while, this brought peace with Rouran.
Later in 538, with Western Wei then controlling the old Northern Wei capital Luoyang, but with Luoyang under attack, Emperor Wen and Yuwen led troops to reinforce Luoyang's defenses, leaving the official Zhou Huida and Crown Prince Qin in Chang'an. However, with the forces engaged in battle, Emperor Wen eventually became stuck at Hengnong , when Chang'an was taken by rebelling former Eastern Wei troops who had been taken captive previously by Western Wei, forcing Zhou and Crown Prince Qin to flee as well. Yuwen was eventually able to disengage after abandoning Luoyang, and he put down the rebellion, allowing Emperor Wen to return to Chang'an.
Although the former Empress Yifu had been deposed and made a Buddhist nun, Empress Yujiulü was still not happy about her presence in the capital. in 540, Emperor Wen therefore made Yuan Wu the governor of Qin Province , and had Empress Yifu accompany Yuan Wu to Qin Province. However, because he still hoped to welcome her back to the palace one day, he secretly told her to keep her hair uncut, rather than shaved like a Buddhist nun. At this time, however, Rouran made a major attack on Western Wei, and many officials thought that the attack was on behalf of Empress Yujiulü. Emperor Wen felt compelled to order Empress Yifu to commit suicide, and he did. Soon thereafter, Empress Yujiulü, who was pregnant, died during childbirth.
In 548, Yuwen and Yuan Qin were on a grand tour of the provinces when Emperor Wen grew ill, and when they heard the news, Yuwen returned to Chang'an quickly, although by the time they returned, Emperor Wen had recovered.
In 549, Emperor Wen issued an edict -- probably as Yuwen requested -- ordering that the names of the ethnic Xianbei, during the reign of Emperor Xiaowen, be changed back to the original Xianbei names.
In 550, Gao Huan's son forced Eastern Wei's Emperor Xiaojing to yield the throne to him, ending Eastern Wei and starting Northern Qi . Emperor Wen therefore became the only claimant to the Northern Wei throne. Yuwen, declaring Northern Qi a rebel state, launched a major attack, but Gao Yang himself commanded a large army to defend against the attack, and Western Wei not only did not make gains, but lost a number of provinces to Northern Qi.
In 551, Emperor Wen died and was buried with honors due an emperor, with Empress Yujiulü, although eventually Empress Yifu was buried with him. Yuan Qin succeeded him .
* ''Datong'' 535-551
** Yuan Yu , the Prince of Jingzhao, son of Emperor Xiaowen of Northern Wei, posthumously honored as Emperor Wenjing
** Lady Yang, likely Yuan Yu's concubine, posthumously honored as Empress Wenjing
** Empress Yifu , mother of Crown Prince Qin and Prince Wu
** Empress Yujiulü , daughter of Rouran's Chiliantoubingdoufa Khan Yujiulü Anagui
** Yuan Qin , the Crown Prince , later Emperor Fei of Western Wei
** Yuan Jian , Prince
** Yuan Ning , the Prince of Zhao
** Yuan Kuo , the Prince of Qi , later Emperor Gong of Western Wei
** Yuan Ru , the Prince of Yan
** Yuan Gong , the Prince of Wu
** Yuan Wu , the Prince of Wudu
** Princess Anle
** Princess Yiyang
** , the Princess Jin'an, later empress to Emperor Xiaomin of Northern Zhou
** Princess Jinming