Zhangsun Wuji (; died 659), courtesy name Fuji (), formally the Duke of Zhao, was a Chinese politician who served as a chancellor in the early Tang dynasty. He was Empress Zhangsun's brother, which made him a brother-in-law of Emperor Taizong (Li Shimin) and a maternal uncle of Emperor Gaozong (Li Zhi). He was an important advisor to Li Shimin when the latter was still the Prince of Qin during the reign of his father, Emperor Gaozu (Li Yuan). He helped Li Shimin overcome his brothers Li Jiancheng (the Crown Prince) and Li Yuanji (the Prince of Qi) in a succession struggle at the Xuanwu Gate Incident, eventually enabling Li Shimin to become the heir apparent and later the emperor. He was also instrumental in Emperor Taizong's selection of Li Zhi as the Crown Prince, and was exceedingly powerful after Li Zhi took the throne as Emperor Gaozong. However, he gradually fell out of his nephew's favour by failing to support Emperor Gaozong's decision to depose his first wife, Empress Wang, and replacing her with Empress Wu, especially after the beginning of the new year 657 with the power of Empress Wu fell more. In 659, Zhangsun Wuji was falsely accused of treason by Empress Wu's political ally, Xu Jingzong, and eventually ordered to be sent into exile by Emperor Gaozong. Xu Jingzong subsequently sent the official Yuan Gongyu () to force Zhangsun Wuji to commit suicide on his way to exile.

Early life It is not known when Zhangsun Wuji was born, but what is known is that he was older than his sister, the future Empress Zhangsun, who was born in 601. It was written that his ancestors traced their origin to the Xianbei dynasty Northern Wei's founding emperor Emperor Taiwu of Northern Wei's 17th generation ancestor Tuoba Kuaili ()—that their ancestor was Tuoba Kuali's third son, who took the surname Baba (), eventually changed to Zhangsun when Emperor Xiaowen of Northern Wei changed Xianbei surnames to Han surnames in 496.

His father was the Sui dynasty general Zhangsun Sheng (), and his mother was Zhangsun Sheng's wife Lady Gao, the daughter of the official Gao Jingde ().While historical records clearly state that Lady Gao was Zhangsun Sheng's wife, she might have not been his first wife, as while it was possible that Zhangsun Wuji's older brother Zhangsun Anye, who was said to have expelled Zhangsun Wuji and Empress Zhangsun from the Zhangsun household, could have done so merely on pure strength, he might not have otherwise had the authority to do so had his mother not also have been a wife (i.e., a wife who died prior to Zhangsun Sheng's marriage to Lady Gao) rather than a concubine. He had at least three older brothers—Zhangsun Sheng's oldest son Zhangsun Xingbu (, who was killed in 604 while resisting the rebellion of Emperor Yang of Sui's brother Yang Liang the Prince of Han), Zhangsun Heng'an (), and Zhangsun Anye (). (Empress Zhangsun was also born of Lady Gao, while Zhangsun Anye was not; who Zhangsun Xingbu's and Zhangsun Heng'an's mothers were was not recorded in history.) Zhangsun Sheng died in 609, and Zhangsun Anye, instead of raising his younger brother and sister, expelled them, as well as his stepmother Lady Gao, from the Zhangsun household and sent them back to Lady Gao's brother Gao Shilian, and Gao Shilian raised them.

It was said that Zhangsun Wuji was studious, and that he was both intelligent and full of strategies. When his sister later married Li Shimin, the second son of the general Li Yuan, he and Li Shimin became great friends. When Li Yuan, at Li Shimin's instigation, rose against the rule of Emperor Yang of Sui in 617 and attacked the capital Chang'an, Zhangsun Wuji went to meet Li Shimin, then serving as a major general of his father's, and he began to serve on Li Shimin's staff, often following Li Shimin on various campaigns.

During Emperor Gaozu's reign Li Yuan captured Chang'an in winter 617 and declared Emperor Yang's grandson Yang You emperor (as Emperor Gong), taking power himself as regent. After he received news in spring 618 that Emperor Yang had been killed at Jiangdu (江都, in modern Yangzhou, Jiangsu) in a coup led by the general Yuwen Huaji, he had Yang You yield the throne to him, establishing Tang dynasty as its Emperor Gaozu. Li Shimin was created the Prince of Qin and thereafter became the main general in charge of his father's campaigns to reunify China under Tang rule, which was largely complete by 623, when the last major rival to Tang, Liu Heita the Prince of Handong, was captured and killed by Li Shimin's older brother, Li Jiancheng the Crown Prince. For Zhangsun Wuji's contributions to Li Shimin's campaigns, he was created the Duke of Shangdang.

Incident at Xuanwu Gate

By 623, however, Li Shimin was locked into an intense rivalry with Li Jiancheng, who was supported by another brother, Li Yuanji the Prince of Qi. For the next several years, the rivalry further intensified. By 626, Li Jiancheng and Li Yuanji, apprehensive that Li Shimin might act against them, had falsely accused Li Shimin's staff strategists Fang Xuanling and Du Ruhui and military officer Yuchi Gong and had them removed from Li Shimin's staff. It was said that by that time, of Li Shimin's closest confidants, only Zhangsun remained, and that Zhangsun, his uncle Gao Shilian, Hou Junji, and Yuchi advocated acting first against Li Jiancheng and Li Yuanji. They persuaded Li Shimin to take action. Li Shimin thereafter set up an ambush for Li Jiancheng and Li Yuanji, killing them at Xuanwu Gate, and then effectively forced Emperor Gaozu to create him crown prince. Zhangsun was thereafter made the minister of civil service affairs. Two months later, Emperor Gaozu yielded the throne to Li Shimin, who took the throne as Emperor Taizong.

During Emperor Taizong's reign Late in 626, when Emperor Taizong personally ranked the contributions of the generals and officials in order to grant them fiefs, Emperor Taizong ranked five of them—Zhangsun Wuji, Fang Xuanling, Du Ruhui, Yuchi Gong, and Hou Junji to be contributors of the highest grade, and Zhangsun was created the Duke of Qi. As Zhangsun was both a great contributor to his victory and a close relative, Emperor Taizong was particularly close to him, allowing Zhangsun to enter the palace frequently.

In spring 627, when the general Li Yi, an associate of Li Jiancheng's, rebelled at Bin Prefecture (, in modern Xianyang, Shaanxi), Emperor Taizong sent Zhangsun to engage Li Yi, although before Zhangsun could arrive, Li Yi had been defeated by his own subordinates and killed in flight. In fall 627, Emperor Taizong, despite opposition from Empress Zhangsun (who feared that the Zhangsun clan was becoming overly honored and would become a target of attack), Emperor Taizong made Zhangsun Wuji Puye (僕射), one of the heads of the important executive bureau of the government and a post considered one for a chancellor. Later that year, when Emperor Taizong heard that Eastern Tujue's Jiali Khan Ashina Duobi, who had made a deep incursion to Chang'an when Emperor Taizong first took the throne in 626, was having internal problems with his subordinates, he consulted Zhangsun and Xiao Yu, asking for their opinions. Xiao advocated an attack on Eastern Tujue, but Zhangsun pointed out that the peace treaty between the two states should not be breached, and Emperor Taizong accepted his suggestion.

Many officials were critical of Zhangsun Wuji's ascension to a chancellor post, and there were secret accusations made to Emperor Taizong that Zhangsun was monopolizing power. Emperor Taizong publicly declared confidence in Zhangsun, but he himself feared that he was a target of resentment. He repeatedly offered to resign, both directly and through Empress Zhangsun, and in spring 628, Emperor Taizong accepted the resignation, although he conferred on Zhangsun the honorific position of Kaifu Yitong Sansi () and continued to consult Zhangsun on many important matters. In 633, Emperor Taizong conferred on Zhangsun the even greater honor of Sikong (): one of the Three Excellencies.

In 637, a major revision of the Sui penal laws, led by Fang but assisted by Zhangsun, was completed, with 500 sections dividing the punishments into 20 grades. About 1,600 sections of regulations to implement the laws were also written.

Also in 637, as part of Emperor Taizong's scheme to bestow prefectures on his relatives and great generals and officials as their permanent domains, Zhangsun's title was changed to Duke of Zhao, and he was given the post of prefect of Zhao Prefecture (, roughly modern Shijiazhuang, Hebei), to be inherited by his heirs. Many officials opposed the plan, with the strongest opposition coming from Zhangsun, who also had his daughter-in-law, Princess Changle (Emperor Taizong's daughter) submit oppositions on his behalf as well, and Emperor Taizong cancelled the scheme, although Zhangsun's title remained Duke of Zhao. In 642, Emperor Taizong changed Zhangsun's honorific from Sikong to Situ (). In 643, when Emperor Taizong commissioned the Portraits at Lingyan Pavilion to commemorate the 24 great contributors to Tang rule, Zhangsun's was one of the portraits commissioned—indeed, Zhangsun's portraits was ranked first.

Succession dispute Later in 643, Li Chengqian the Crown Prince (the oldest son of Emperor Taizong and Empress Zhangsun, who had died in 636), locked into an intense rivalry with his younger brother Li Tai the Prince of Wei, who was also born of Empress Zhangsun and was Emperor Taizong's favorite son, was discovered to have plotted to overthrow Emperor Taizong, along with Hou Junji and Emperor Taizong's sons-in-law Zhao Jie () and Du He (, Du Ruhui's son). Emperor Taizong put the investigation in the hands of Zhangsun, Fang Xuanling, Xiao Yu, Li Shiji, and the officials in charge of the supreme court and the legislative and examination bureaus of government, and they determined that, indeed, Li Chengqian had plotted to overthrow Emperor Taizong. Li Chengqian was deposed, while his coconspirators were executed.

A succession question immediately arose. Li Tai was Emperor Taizong's favorite son, and Emperor Taizong almost immediately promised to him that he would be created crown prince, an idea concurred by the chancellors Cen Wenben and Liu Ji. However, Zhangsun did not concur, and instead recommended that Emperor Taizong make his ninth son Li Zhi, also by Empress Zhangsun, crown prince instead; Zhangsun was supported in this suggestion by Chu Suiliang. Further, when Emperor Taizong interrogated Li Chengqian personally, Li Chengqian admitted guilt but blamed Li Tai's machinations for leading him to fear for his own safety and thus plot rebellion. Emperor Taizong thereafter resolved to create Li Zhi crown prince—a decision that he initially secretly informed only Zhangsun, Fang, Li Shiji, and Chu, in addition to Li Zhi himself—and he exiled both Li Chengqian and Li Tai. Subsequently, Zhangsun, along with Fang and Xiao, were made senior advisors to the new crown prince. Thereafter, however, Emperor Taizong began to doubt whether his decision was correct—believing that while Li Zhi was kind, he was also weak in personality, and unsure whether he would be fit to be emperor. He discussed with Zhangsun the possibility of making another son, Li Ke the Prince of Wu (by his concubine Consort Yang, a daughter of Sui's Emperor Yang), who was older than Li Zhi and considered more capable, crown prince instead. Zhangsun strenuously opposed this idea, and Emperor Taizong did not carry it out. Zhangsun further often praised Li Zhi's kindness. Thereafter, a deep enmity developed between Zhangsun and Li Ke.

In 644, when Emperor Taizong, at an imperial gathering, stated to his key officials their strengths and weaknesses, he spoke, with regard to Zhangsun: