The first conflict of the Goguryeo–Tang War started when Emperor Taizong () of the Tang dynasty led a military campaign against Goguryeo in 645 to protect Silla and punish Generalissimo Yeon Gaesomun for the killing of King Yeongnyu. The Tang forces were commanded by Emperor Taizong himself, and generals Li Shiji, Li Daozong, and Zhangsun Wuji.
In 645, after capturing multiple Goguryeo fortresses and defeating large armies in his path, Emperor Taizong appeared poised to march on the capital Pyongyang and conquer Goguryeo, but could not overcome the strong defenses at Ansi Fortress, which was commanded by Yang Manchun at the time. Emperor Taizong withdrew after more than 60 days of battle and unsuccessful siege.
Background
In 642, Goguryeo had enjoyed nearly 700 years of independence since Dongmyeong defeated all the opposition and the Han dynasty. Goguryeo reached its peak during the reign of Gwanggaeto the Great, who ruled the kingdom from 391 to 413. Under his reign, Goguryeo became one of the great powers in East Asia, subdued neighboring kingdoms and achieved a loose unification of the Korean peninsula. After a period of prosperity, Goguryeo began to decline in the end of the 5th century due to internal strife.
In 551, the two southern countries, Baekje and Silla, allied with each other and attacked the Han River basin region. Silla then betrayed Baekje and drove its forces out of the region, thus securing for itself the whole Han River basin. Furiously, the king of Baekje decided to attack Silla, but because the army was exhausted, Baekje lost the battle and the king himself died. Silla gained access to the Yellow Sea, which provided a gateway to communicate with China. This created conditions for the relationship between Silla and the Chinese dynasties to gradually tighten and by the 7th century, it became an alliance, threatening Goguryeo from both sides.
At the end of the 6th century, wars broke out between the Sui dynasty and Goguryeo. Sui dynasty launched a total of 4 invasions, in 598, 612, 613 and 614, but all were defeated. Notably, in 612, Emperor Yang of Sui mobilized an army of up to a million men to attack Goguryeo but failed miserably. The wars with Goguryeo severely weakened the Sui dynasty and further destabilized of the Sui dynasty government, hastening its collapse.
In 7th century, Emperor Taizong of Tang, after conquering the Eastern Turks in 630 and several small polities along the Silk Road in 640, started to turn his attention to Goguryeo. Goguryeo was no longer as powerful as it used to be, but it was still a major force in the region. Emperor Taizong had a personal ambition to defeat Goguryeo and was determined to succeed where Emperor Yang had failed.
Meanwhile, in Goguryeo, King Yeongnyu along with a number of courtiers planned to execute Yeon Gaesomun, one of the great nobles of Goguryeo, because Yeongnyu considered him a threat. However, the plot was foiled and Yeon Gaesomun killed the king along with opposing officials, then made Yeongnyu's nephew Bojang the new King of Goguryeo. From that point, Yeon Gaesomun held de facto control of Goguryeo through his puppet King Bojang.
In 642, King Uija of Baekje attacked Silla and captured around 40 strongpoints. In 643, Queen Seondeok of Silla requested aid from the Tang dynasty because her state was under attack by the Goguryeo–Baekje alliance. Emperor Taizong sent an official called Xiangli Xuanjiang (相里玄獎) to demand Goguryeo and Baekje cease their attacks on Silla, but Yeon Gaesomun refused.
Course
Emperor Taizong used Yeon Gaesomun's murder of the Goguryeo king as a pretext, and began preparations for an invasion in 644. On land, an army of 60,000 Tang soldiers and an unspecified number of tribal forces gathered at Youzhou, under the command of General Li Shiji in April 645. Emperor Taizong personally commanded 10,000 armored cavalry, and would join and reinforce Li Shiji's army during the expedition. At sea, a great fleet of 500 ships transported an additional 40,000 conscripted soldiers and 3,000 military gentlemen (volunteers from the elite of Chang'an and Luoyang) from the Liaodong Peninsula to the Korean Peninsula.