Emperor Wen of Western Wei ((西)魏文帝) (507–551), personal name Yuan Baoju (元寶炬), was an emperor of Western Wei—a branch successor state to Northern Wei. In 534, Yuan Baoju, then the Prince of Nanyang, followed his cousin Emperor Xiaowu in fleeing from the capital Luoyang to Chang'an, after a fallout between Emperor Xiaowu and the paramount general Gao Huan. However, Emperor Xiaowu's relationship to the general that he then depended on, Yuwen Tai, soon deteriorated as well, and around the new year 535, Yuwen Tai poisoned Emperor Xiaowu to death, making Yuan Baoju emperor (as Emperor Wen). As Gao Huan had, late in 534, made Yuan Shanjian the son of Emperor Wen's cousin Yuan Dan (元亶) the Prince of Qinghe emperor (as Emperor Xiaojing), thus establishing Eastern Wei, Emperor Wen was known as Western Wei's first emperor, formalizing the division. Emperor Wen's relationship with Yuwen appeared cordial, but he was unable to exercise much real power.
Yuan Baoju was born in 507, a member of the Tuoba clan of the Xianbei. His father Yuan Yu (元愉), the Prince of Jingzhao, was the son of Emperor Xiaowen and a younger brother of the reigning Emperor Xuanwu. His mother was recorded as Yuan Yu's concubine Yang Aofei(杨奥妃). He had three other brothers, at least one of whom, Yuan Baoyue (元寶月), was older, and born of Yang Aofei.
Yuan Yu favored Yang Aofei but not his wife, Princess Yu, a sister to Emperor Xuanwu's wife Empress Yu. Consequently, Empress Yu once summoned Yang Aofei 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 Yang Aofei 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 (冀州, modern central Hebei). In anger, he rebelled at the capital of Ji Province, Xindu (信都, in modern Hengshui, Hebei), 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, Yang Aofei 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 Yang Aofei 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, Emperor Xiaoming's mother Empress Dowager Hu 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 rehabilitation 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 Lady Yifu, the daughter of a moderately prominent aristocratic family. (In his youth, Yuan Baoju was described by the Book of Wei as frivolous, alcoholic, and sexually immoral, but this description is highly suspect in that the Book of Wei was written by Wei Shou, an official of Eastern Wei, the rival of Western Wei, for which Yuan Baoju would eventually become emperor.) In 528, Emperor Xiaoming created him the Marquess of Shao County, and in 530, Emperor Xiaozhuang created him the Prince of Nanyang.
In 532, after several years of civil war, the victorious general Gao Huan made Yuan Baoju's cousin Yuan Xiu the Prince of Pingyang emperor (as Emperor Xiaowu). 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 Emperor Wen). As Gao had earlier declared Yuan Shanjian, 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 (Emperor Xiaojing) 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 Yuan Qin 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 Yujiulü Anagui's daughter. 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 (temporariily) controlling the old Northern Wei capital Luoyang, but with Luoyang under attack, Emperor Wen (who had wanted to visit the imperial ancestral tombs in Luoyang) 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 (恆農, in modern Sanmenxia, Henan), 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 (秦州, roughly modern Tianshui, Gansu), 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, changed to Han names during the reign of Emperor Xiaowen, be changed back to the original Xianbei names.
In 550, Gao Huan's son Gao Yang forced Eastern Wei's Emperor Xiaojing to yield the throne to him, ending Eastern Wei and starting Northern Qi (as its Emperor Wenxuan). 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. (It is not clear whether she displaced Empress Yujiulü or not.) Yuan Qin succeeded him (as Emperor Fei).
- Datong (大統 dà tǒng) 535-551
- Yuan Yu (元愉) (488-508), the Prince of Jingzhao, son of Emperor Xiaowen of Northern Wei, posthumously honored as Emperor Wenjing
- Lady Yang Aofei（杨奥妃）, Yuan Yu's concubine, posthumously honored as Empress Wenjing
- Empress Yifu (created 535, deposed 538, forced to commit suicide 540), mother of Crown Prince Qin and Prince Wu
- Empress Yujiulü (created 538, d. 540), daughter of Rouran's Chiliantoubingdoufa Khan Yujiulü Anagui
- Yuan Qin (元欽), the Crown Prince (created 535), later Emperor Fei of Western Wei
- Yuan Jian (元儉), the Prince of Liang (created 545)
- Yuan Ning (元寧), the Prince of Zhao (created 547)
- Yuan Kuo (元廓), the Prince of Qi (created 548), later Emperor Gong of Western Wei
- Yuan Ru (元儒), the Prince of Yan (created 550)
- Yuan Gong (元公), the Prince of Wu (created 550)
- Yuan Wu (元戊), the Prince of Wudu
- Princess Anle
- Princess Yiyang
- Yuan Humo (元胡摩), the Princess Jin'an, later empress to Emperor Xiaomin of Northern Zhou
- Princess Jinming, married Yuchi Jiong and was the grandmother of Yuchi Chifan