In 644, when Emperor Taizong planned a major campaign against Goguryeo, Zhang repeatedly advised against it, but Emperor Taizong did not accept his advice. 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. Later, however, when Emperor Taizong's own main forces became bogged down in sieging Ansi (, in modern Anshan, Liaoning) and was eventually forced to abandon the offensive with winter arriving, Zhang withdrew as well.