Li Yuanji
By 626, Li Shimin was locked in an intense rivalry with his elder brother, Li Jiancheng (the Crown Prince), and he considered actions to take. As Li Shimin contemplated the possibility that he might eventually need to seize Luoyang to serve as a basis of operations against Li Jiancheng, he sent Zhang to Luoyang, with several thousand men, to secretly plan for that possibility, and to distribute wealth to get people to join Li Shimin's cause. However, this was discovered by Li Shimin's younger brother, Li Yuanji (the Prince of Qi), who supported Li Jiancheng, and Li Yuanji accused Zhang of treason. Zhang was briefly put under arrest, but under interrogation refused to reveal Li Shimin's instructions to him, and with insufficient evidence against himself, he was released and allowed to return to Luoyang. Later that year, after Li Shimin ambushed Li Jiancheng and Li Yuanji at Xuanwu Gate and killed them, he effectively forced Emperor Gaozu to create him crown prince and then yield the throne to him (as Emperor Taizong).