Pakistan took the lead in the 31st minute after Vietnam lost possession in their own half. A careless back pass and an indecisive clearance by Le Ngoc Bao allowed Mohib Ullah to break through and beat goalkeeper Patrik Le Giang.
Vietnam struggled to create clear chances before halftime. Nguyen Hoang Duc tested Pakistan goalkeeper Yousuf Butt with a long-range shot in the 41st minute, while Williams Minh Hoang missed from close range shortly before the break.
Vietnam made a change at halftime, with Phan Tuan Tai replacing Cao Pendant Quang Vinh.
The move quickly paid off. In the 50th minute, Tuan Tai played a through ball down the left to Nguyen Hai Long, who cut inside before curling the ball past Butt to level the score.
Vietnam completed the comeback seven minutes later. Nguyen Dinh Bac sprinted down the left and laid the ball back for Hoang Duc, who struck a powerful shot into the net to make it 2-1.
Pakistan responded by pushing forward, but Vietnam's defense held firm. Bui Hoang Viet Anh made several important interventions, including blocking a shot from Umar Nawaz and covering after Ali Khan beat Pham Xuan Manh in a one-on-one.
Vietnam slowed the pace after taking the lead and looked for opportunities on the counterattack. Dinh Bac created another chance in the 85th minute, dribbling past his marker before setting up Hai Long, whose shot went over the bar.
Pakistan then pulled level with two minutes of normal time remaining. Ali Khan's shot deflected off a teammate's foot and wrong-footed Patrik Le Giang to make it 2-3.
Vietnam restored its two-goal advantage in the first minute of stoppage time. Williams Minh Hoang received a through pass and finished with his left foot to score his first goal for Vietnam.
The 19-year-old Vietnamese-English striker had earlier missed a chance in the first half and headed over the bar in the 66th minute.
Vietnam held on for a 4-2 victory and advanced to the third-place match, where they will face Malaysia.
FIFA ASEAN Cup: Vietnam 4-2 Pakistan