The Goryeo–Khitan War was a series of 10th- and 11th-century conflicts between Goryeo and the Khitan Liao dynasty near the present-day border between China and North Korea.
Background
During the Three Kingdoms of Korea period, Goguryeo occupied the northern Korean Peninsula and parts of Manchuria and Inner Mongolia. With Goguryeo's fall in 668, Silla unified the Three Kingdoms, while northern parts of Goguryeo territory were briefly occupied by Silla's ally, Tang dynasty. A former Goguryeo general revived Goguryeo's Manchurian territory as the new kingdom of Balhae. Right after the fall of Goguryeo, the Göktürks were divided and eventually driven out from most of Central Asia by the Tang dynasty. Another Turkic tribe, the Uyghurs, replaced the Göktürks, but their control was weak. As Balhae, the Uyghur and the Tang dynasty weakened, the Khitan people, a nomadic confederation in Manchuria and eastern Mongolia, grew stronger and began to expand their territory. Following Tang's collapse in 907, China experienced a long period of civil war. In 911, threatened by Khitan expansion, Balhae sought help from the declining Silla of the Korean Peninsula. Records stated that Balhae also requested help from Silla's successor dynasty Goryeo during the Later Three Kingdoms. In 916, the Liao dynasty was founded by the Khitan chief Yelü Abaoji, who was enthroned as Emperor Taizu of Liao, replacing the Uyghurs as the dominant power of what is now Mongolia after the Yenisei Kyrgyz and the Tang dynasty defeated the Uyghur Khaganate and left a power vacuum.
Goryeo–Khitan relations
On the Korean Peninsula, Silla was succeeded by Goryeo in 918. The Khitan destroyed Balhae in 926, with Balhae refugees forced migration by the Liao Empire, a portion of its people including the ruling class moved south and joined the newly founded Goryeo Dynasty. The Khitan took control of the Sixteen Prefectures south of the Great Wall for helping the foundation of the short-lived Later Jin Dynasty, which ruled only Zhongyuan, a small part of China. In 922, the Khitan leader Yelü Abaoji sent horses and camels to Goryeo as gifts of friendship. However, when Balhae fell to the Khitan a few years later, King Taejo embraced refugees from Balhae and pursued a policy of northern expansion. In 942, the Khitan sent another 50 camels to Goryeo, but this time Taejo refused the gift, exiled the envoy to an island, and had the camels starved to death. Succeeding Goryeo rulers continued the anti-Khitan policy. Jeongjong, 3rd Monarch of Goryeo, raised an army of 300,000 to defend against the Khitan. Gwangjong of Goryeo built fortresses along the northwest and aggressively developed the military fortifications of present-day Pyongan and Hamgyong provinces.
Liao's expansion
In 962, Gwangjong allied with the Song dynasty of central China and pursued a northern expansion policy. Additionally, some Balhae refugees had formed a small state called Jeongan in mid-Yalu River region and allied with Song and Goryeo against the Khitan. The Khitan eventually regained internal stability under the strong leadership of Emperor Shengzong of Liao, who sought to counter regional isolation. After conquering Jeongan-guk in 986 and attacking the Jurchens on the lower Yalu River in 991, the Khitans initiated attacks against Goryeo.
First Invasion
In 993, the Khitan invaded Goryeo's northwestern border with an army that the Liao commander claimed to number 800,000. After a military stalemate, negotiations began between the two states, producing the following concessions: Firstly, Goryeo formally ended all relations with the Song dynasty, agreed to pay tribute to Liao and to adopt Liao's calendar. Secondly, after negotiations led by the Goryeo diplomat Seo Hui, Goryeo formally incorporated the land between the border of Liao and Goryeo up to the Yalu River, which was at the time occupied by troublesome Jurchen tribes, citing that in the past the land belonged to Goguryeo, the predecessor to Goryeo. With this agreement, the Khitans withdrew. However, in spite of the settlement, Goryeo continued to communicate with Song, having strengthened its defenses by building fortresses in the newly gained northern territories.
Second Invasion
In 1009, General Gang Jo 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. Gang Jo blocked the Liao's first attack, but he was defeated in the second one and was executed. King Hyeonjong of Goryeo was forced to flee the capital, which was sacked and burnt by the Khitan, to Naju temporarily. Unable to establish a foothold and to avoid a counterattack by the regrouped Korean armies, the Khitan 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.
Third Invasion
In 1018, Liao assembled an army of 100,000 troops to invade Goryeo. In preparation, General Gang Gam-chan ordered a stream to the east of Heunghwajin to be dammed. When the Khitan troops crossed the Yalu River, Gang Gam-chan 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 Khitan troops soldiered on and headed toward the capital, but were met with stiff resistance and constant attacks, and were forced to retreat back north. Gang Gam-chan and his troops waited at Gwiju and surrounded the Khitan, annihilating most of them. Barely a few thousand Liao troops survived after the Battle of Gwiju. In the next year, however, the Liao assembled another large army. Understanding the difficulty of achieving a decisive victory, the two nations signed a peace treaty in 1022.