Wei Wen (韋溫) (died July 24, 710) was an official of the Chinese dynasty Tang Dynasty, serving as a chancellor during the reigns of Emperor Zhongzong and Emperor Zhongzong's son Emperor Shang. He was trusted by Emperor Zhongzong's powerful wife Empress Wei, who was his cousin, and after she was killed in a coup after Emperor Zhongzong's death, he was also killed.
It is not known when Wei Wen was born. His father was Wei Xuanyan (韋玄儼), who served as a prefectural prefect late in the reign of Emperor Gaozong. Wei Wen's cousin—the daughter of Wei Xuanyan's younger brother Wei Xuanzhen (韋玄貞) -- was the wife and crown princess of Emperor Gaozong's son Li Zhe the Crown Prince, and on that account was quickly promoted. After Emperor Gaozong's death in 683, Li Zhe took the throne (as Emperor Zhongzong), but soon ran afoul of his mother Empress Dowager Wu (later known as Wu Zetian), who retained power as regent, partly over his desire to promote Wei Xuanzhen to be chancellor. In spring 684, she deposed Emperor Zhongzong to be the Prince of Luling and exiled him and his wife. (She subsequently took the throne herself as "emperor" in 690.) Wei Wen thus, for the time being, received no help from his relationship with his cousin, and when he served as a probationary official, he was accused of receiving bribes and removed from his office.
During Emperor Zhongzong's second reign
In 705, Wu Zetian was overthrown, and Li Zhe, then carrying the title of crown prince and having changed his name to Li Xian, returned to the throne. His wife again became empress, and Wei Wen, as her closest male relative (as her father Wei Xuanzhen had died in exile and her brothers Wei Xun (韋洵), Wei Hao (韋浩), Wei Dong (韋洞), and Wei Ci (韋泚) had been killed by the local tribal chieftain Ning Chengji (寧承基)), was made the minister of rites (禮部尚書, Libu Shangshu) and created the Duke of Lu. Many of his relatives also were honored, as Empress Wei wanted to promote her relatives.
In 709, Wei Wen was made Taizi Shaobao (太子少保), an advisor to the crown prince (but entirely honorary post at that time, as there was no crown prince) and given the designation Tong Zhongshu Menxia Sanpin (同中書門下三品), making him a de facto chancellor.
In 710, Emperor Zhongzong died suddenly—a death that traditional historians believed to be a poisoning carried out by Empress Wei and her daughter Li Guo'er the Princess Anle, so that Empress Wei could eventually be "emperor" like Wu Zetian, and Li Guo'er could be crown princess. Empress Wei initially did not announce Emperor Zhongzong's death, and immediately put Wei Wen in overall command of the imperial guards, with his cousin Wei Xuan (韋璿) and nephews Wei Bo (韋播) and Gao Song (高嵩) in command as well.
Meanwhile, though, under a plan drafted by Emperor Zhongzong's sister Princess Taiping and concubine Consort Shangguan Wan'er, Emperor Zhongzong's son by another concubine, Li Chongmao would be named emperor. Empress Wei would serve as empress dowager and regent, while Emperor Zhongzong's younger brother Li Dan the Prince of Xiang, himself a former emperor, would serve as coregent; Consort Shangguan subsequently formalized this in a will she drafted posthumously for Emperor Zhongzong. Wei Wen and another chancellor, Zong Chuke, however, opposed this plan on the grounds that this would require her and Li Dan to frequently confer, which violated Confucian principles that a brother-in-law and a sister-in-law should not converse with each other. Under Zong's and Wei Wen's insistence, the other chancellors did not dare to oppose their will, and Li Dan was not made coregent. Li Chongmao soon took the throne (as Emperor Shang), with Empress Wei serving as empress dowager and regent.
Meanwhile, Zong feared Li Dan and Princess Taiping, and was advocating to Empress Dowager Wei and Wei Wen that Li Dan and Princess Taiping should be killed. At the same time, though, Princess Taiping and Li Dan's son Li Longji had received news of this and were planning a coup—which was facilitated by that Wei Bo and Gao were alienating the imperial guards by being harsh to the guards, trying to establish their authority. Li Longji took this opportunity to encourage the guard commanders to rise against the Wei party, and on July 21, Princess Taiping and Li Longji, with the imperial guards' support, rose in rebellion, killing Empress Dowager Wei and Li Guo'er. Li Dan was named regent. Wei Xuan, Wei Bo, and Gao were killed on during the coup, but Wei Wen was not executed until July 24, for reasons unclear in history. After his death, his clan was massacred.