However, around the same time, Wang Shichong captured Zheng Prefecture, and Zhang had nowhere to go, and instead took up guerilla warfare in the region.
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.
For Zhang's contributions, Emperor Taizong enfeoffed him as the Duke of Changping and made him the commandant at Huai Prefecture (懷州, roughly modern Jiaozuo, Henan).
When they went to Xiang Prefecture, there was a young man who sold pens for a living and was good at singing and dancing.
In 641, he was made the head of the household for Emperor Taizong's son and crown prince, Li Chengqian, but was also sent out of the capital to serve as the commandant at Luo Prefecture (i.e., modern-day Luoyang, Henan).
The general Hou Junji, who was unhappy that he had been briefly imprisoned on accusations of embezzlement after he conquered Gaochang, tried to instigate Zhang by asking him, "Who squeezed you out?"
Hou responded, "I conquered a kingdom, but I ran into someone throwing a tamper tantrum big enough to overturn a house.
Zhang himself thereafter requested to be a general on the campaign, and he was put in charge of the 40,000 soldier fleet that would depart from Lai Prefecture to head directly toward the Goguryeo capital Pyongyang.
In summer 645, Zhang's fleet attacked and captured Bisa (卑沙, in modern Dalian, Liaoning), and then headed to the mouth of the Yalu River in anticipation of the army also arriving there.
When his forces subsequently marched past Geonan (建安, in modern Yingkou, Liaoning), Goguryeo forces made a surprise attack against his forces—shocking him so much that he froze, but his failure to react was interpreted by his own soldiers to be a show of resolve and bravery, and his assistant Zhang Jinshu (張金樹) subsequently counterattacked and repelled the Goguryeo attack.
In 646, one Chang Dexuan (常德玄) reported to Emperor Taizong these things and suggested that Zhang was plotting treason.