The Third Goryeo–Khitan War (Chinese: 第三次高麗契丹戰爭; Korean: 제3차 고려-거란 전쟁) was an 11th-century conflict between the Goryeo dynasty of Korea and the Khitan-led Liao dynasty of China near what is now the border between China and North Korea.
The army crossed the Yalu in late 1018 but was ambushed by a superior Goryeo force and suffered severe losses.
However the Goryeo army had cut their line of retreat, so Xiao Paiya marched south with the intent of taking Kaesong.
[9][10] According to Korean sources, only a few thousand men managed to retreat to the Liao border.
At this point both sides realized that they could not defeat each other militarily, so in 1020 King Hyeonjong resumed sending tribute, and in 1022 the Khitans officially recognized the legitimacy of King Hyeonjong's reign.