In 666, Yeon Gaesomun died and Goguryeo became plagued by violent dissension, numerous defections, and widespread demoralization.
These newly formed governments in Baekje and Goguryeo were preparing for war and had established a mutual alliance against Tang and Silla.
[8][6] Emperor Taizong of Tang used Yeon Gaesomun's murder of King Yeongnyu of Goguryeo as the pretext for his campaign and started preparations for an invasion force in 644.
General Li Shiji commanded an army of 60,000 Tang soldiers and an undisclosed number of tribal forces which gathered at Youzhou.
Emperor Taizong commanded an armored cavalry of 10,000 strong, which eventually met up and joined general Li Shiji's army during the expedition.
A fleet of 500 ships also transported an additional 40,000 conscripted soldiers and 3,000 military gentlemen (volunteers from the elite of Chang'an and Luoyang).
On 16 May, they laid siege to Gaimou (Kaemo), which fell after only 11 days, capturing 20,000 people and confiscating 100,000 shi (6 million liters) of grain.
Of these prisoners, the Tang forces sent 3,500 officers and chieftains to China, executed 3,300 Mohe troops, and eventually released the rest of the ordinary Goguryeo soldiers.
Facing worsened conditions for the Tang army due to cold weather (winter was approaching) and diminishing provisions, Emperor Taizong was compelled to order a withdrawal from Goguryeo on October 13.
[14][10] Taizong himself tended to the injuries of the Göktürk generals Qibi Heli and Ashina Simo, who were both wounded during the campaign against Goguryeo.
Even though Baekje was allied with Goguryeo, the Han River valley separated the two states and was a hindrance in coming to each other's aid in time of war.
[16] The Tang Empire annexed the territory and established five military administrations to control the region instead of Silla, which was painfully accepted.
[23] The Nihongi Chronicles notes that during his pleas for Yamato assistance, Prince Buyeo Pung was conferred the cap of shiki given the younger sister of Komoshi Oho no Omi to wed. Emperor Tenji of Japan sent Ajimasa Sawi no Muraji of Lower Daisen Rank, and Takutsu Hada no Miyakko, in command of four thousand men to escort Prince Buyeo Pung back to his country where General Gwisil Boksin met and entrusted the governance of the land to the prince.
Qibi Heli defeated a Goguryeo army at the Yalu River but Su Dingfang failed to take Pyongyang.
The invasion was called off in February 662 after failing to take Pyongyang for several months and when a subsidiary Tang force led by Pang Xiaotai was defeated by Yeon Gaesomun at the Battle of Sasu.
The violent dissension resulting from Yeon Gaesomun's death proved to be the primary reason for the Tang–Silla triumph, thanks to the division, defections, and widespread demoralization it caused.
[28] By the end of the war, the Tang Empire had taken control over the former territories of Baekje and Goguryeo and tried to assert dominion over Silla.
[31] However, the Tang occupation of the Korean Peninsula proved to be logistically difficult due to shortage of supplies which Silla had provided previously.
[38] Furthermore, Emperor Gaozong was ailing, so Empress Wu took a pacifist policy, and the Tang Empire was diverting resources towards other priorities.