Li Yuanji
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.