Goryeo–Khitan War

The Goryeo–Khitan War (Chinese: 遼麗戰爭; Korean: 고려-거란 전쟁) was a series of 10th- and 11th-century conflicts between the Goryeo dynasty of Korea and the Khitan-led Liao dynasty of China.
Silla experienced a period of decline starting in the latter half of the 9th century that continued until it was ultimately succeeded by Goryeo. This transition followed a time known as the Later Three Kingdoms, marked by conflict between the resurgent aristocracies of Goguryeo, Baekje, and the ruling Silla nobility. In 926, the Khitan-led Liao dynasty conquered Balhae, leading its last crown prince and the survivors to flee southward and seek refuge in Goryeo. This event marked the unification of the two successor states of Goguryeo.
Taejo of Goryeo embraced the refugees from Balhae as his fellow kin and pursued a policy of northern expansion (possibly enabled by the absence of a fellow Korean kingdom in what was once Goguryeo territory). In 942, the Khitan sent 50 camels to Goryeo as a gift. However, due to cold relations, Goryeo declined the gift, banished the envoy to an island, and had the camels die from starvation under a bridge. Hyeonjong ordered preparations in case of an upcoming conflict with the Liao.
In 993, the Liao dynasty launched an invasion against the northwestern frontier of Goryeo with a force that the Liao commander alleged to be 800,000 strong. After a military stalemate, negotiations began between the two states, producing the following concessions: first, Goryeo formally ended all relations with the Song dynasty, agreed to pay tribute to Liao and to adopt Liao's calendar; second, after negotiations led by the Goryeo diplomat Sŏ Hŭi, Goryeo formally incorporated the land between the border of Liao and Goryeo up to the Yalu River, which was at the time occupied by Jurchen tribes, citing that in the past the land belonged to Goguryeo. With this agreement, the Liao forces withdrew. However, in spite of the settlement, Goryeo continued to communicate with the Song, having strengthened its defenses by building fortresses in the newly gained northern territories.
In 1009, General Kang Cho of Goryeo led a coup against King Mokjong, killing him and establishing military rule. The Liao dynasty attacked with 400,000 troops in 1010, claiming to avenge the murdered Mokjong. Kang Cho blocked the Liao's first attack, but he was defeated in the second attack and was executed. King Hyeonjong of Goryeo was forced to flee the capital, which was sacked and burnt by the Liao, to Naju temporarily. Unable to establish a foothold and to avoid a counterattack by the regrouped Goryeo armies, the Liao forces withdrew. Afterward, the Goryeo king sued for peace, but the Liao emperor demanded that he come in person and also cede key border areas to him; the Goryeo court refused the demands, resulting in a decade of hostility between the two nations during which both sides fortified their borders in preparation of war. Liao attacked Goryeo in 1015, 1016, and 1017, but the results were indecisive.
In 1018, Liao assembled an army of 100,000 troops to invade Goryeo. In preparation, General Kang Kam-ch'an ordered a stream to the east of Heunghwajin to be dammed. When the Liao troops crossed the Yalu River, Kang Kam-ch'an opened the dam and attacked the enemy troops with 12,000 mounted troops, catching them by surprise, inflicting severe losses, and cutting off their line of retreat. The Liao troops soldiered on and headed toward the capital, but were met with stiff resistance and constant attacks, and were forced to retreat back north. During the retreat, 10,000 Liao army troops were annihilated by the Goryeo army under Kang Min-cheom of Goryeo. Kang Kam-ch'an and his troops waited at Gwiju and engaged the approaching Liao army, annihilating most of them. Barely a few thousand Liao troops survived after the Battle of Gwiju.
In the next year the Liao assembled another large army in order to launch another invasion but it became clear that neither side could gain a decisive victory. In 1020 King Hyeonjong resumed sending tribute, and in 1022 the Khitans officially recognized the legitimacy of King Hyeonjong's reign. In 1022, a Khitan envoy was sent to invest Hyeongjong as king, and when he died in 1031, his successor Wang Heum was also invested by the Liao court as king. Goryeo broke off relations with Song and the Liao ceded territory around the Yalu to Goryeo. The relationship between Liao and Goryeo would remain peaceful until the end of the Liao dynasty.
In the Goryeo-Liao peace treaty formalized in 1022, the only terms stipulated were that the Goryeo king acknowledge their vassalage to the Liao and to release detained Liao envoys. After 1022, Goryeo did not have diplomatic relations with the Song until 1070, with the exception of an isolated embassy in 1030. The sole embassy was probably related to the rebellion of Balhae people in the Liao dynasty. The rebellion was quickly defeated by the Khitans, who returned to enforce Goryeo's tributary obligations. Goryeo adopted the reign title of the Liao in the fourth month of 1022. However according to Bielenstein, Goryeo maintained diplomatic relations with Song, Hyeonjong kept his own reign title, and the two states concluded peace as equals in 1022.