The battle was joined on 23 June when one of the Goguryeo generals, Ko Yŏnsu, sighted that the Tang army was seemingly smaller and had its lines thinly held. With this, he decided to attack with the cavalry and attempt to dislodge the large Tang army in front of his army. What he did not know is that it was actually a ploy by the Emperor Taizong to lure the Goguryeo army into a trap as earlier planned by his subordinates. The Goguryeo cavalry led by Ko Yŏnsu charged across the plain dominating the battlefield at the foot of Jupil Mountain just south of Ansi, towards the Tang infantry that was awaiting them in a
shield wall formation. The other general, Ko Hyejin , followed suit and also joined the attack. Despite mass projectile shots from archers,
crossbowmen and
catapults just within the Tang formation, the cavalry charge kept up its momentum until it finally impacted the shield wall, causing many Tang casualties in the process as the cavalry charged across. But it soon came as a shock for both generals that behind the long shield wall of the Tang army were massive and dense amounts of infantry with Emperor Taizong and his entourage far behind observing the scene, and yet despite it they continued the assault on the Tang army. The massive Tang battle line thus slowly developed from a straight line into a U-shaped formation as its army purposefully gave way to the Goguryeo attack, giving the Goguryeo a false sense of victory at this stage. When Emperor Taizong finally deemed the time right to spring his trap, he ordered to sound the drums and horns to signal the flanking attack by
Zhangsun Wuji and other generals with an 11,000-strong cavalry detachment from behind hidden in a hill north of Mount Jupil until now. In what seemed to be a
Cannae-like event, the Tang cavalry finally closed in into the rear of the Goguryeo cavalry, hitting it through its rear. The Tang army started pushing and tightening the encirclement even as the two Goguryeo generals tried to rally their men to fight on, but the one-sided mass slaughter continued. Seeing that they could not salvage the situation, the two Goguryeo generals tried as best as they could to get what was left of their force out of the encirclement to rejoin the main body of their army across the river to the south, but 30,000 of their men were killed trying to do so. Worse came when they found out that the bridges in the river that leads them back to the main body of their army were already torn down by the Tang commander
Zhangsun Wuji under orders from Emperor Taizong who already foresaw the event. Finding no other way to rejoin the main body of their army, the two generals rallied whatever remained of their force northwards to the peak of Mount Jupil with the Tang army in hot pursuit. The Tang army then caught up and encircled the remaining Goguryeo force atop Mount Jupil once again. In an attempt to save their beleaguered comrades atop Mount Jupil, the main body of the Goguryeo army finally joined the battle by fording the river and attacked the Tang army. However, they soon found themselves counterattacked on three sides by the Tang army, having failed to reach their comrades atop the mountain. Seeing that all was lost, Ko Yŏnsu and Ko Hyejin surrendered what remained of their command that was stranded atop the mountain, now reduced to just 3,800 wounded and famished men. What remained of the Goguryeo army that had not yet surrendered, that is, the force that tried to save their comrades atop Mount Jupil but failed, is now also subjected by attacks of the Tang army on three sides, pummeling it into a pulp until they finally retreated and dispersed southwards, only to be chased down by the pursuing Tang army with most of them dead during the chase and captured 33,000 Goguryeo soldiers prisoner. Among these, the Tang forces sent 3,500 officers and chieftains back to China, executed 3,300 Mohe troops, and eventually released the rest of the ordinary Goguryeo soldiers. As part of the war spoils taken from the enemy, the Tang army captured from the vanquished Goguryeo army 50,000 horses, 50,000 cows, and 10,000 metal body armor. == Aftermath ==