quality:correction, structural:reformatting
Goryeo dynasty

Goryeo was founded in 918 and replaced Silla as the ruling dynasty of Korea. Goryeo's land was at first what is now South Korea and about 1/3 of North Korea, but later on managed to recover most of the Korean peninsula. Momentarily, Goryeo advanced to parts of Jiandao while conquering the Jurchens, but returned the territories due to the harsh climate and difficulties in defending them. The name "Goryeo" (高麗) is a short form of " Goguryeo " (高句麗) and was first used during the time of King Jangsu. Goryeo regarded itself as the successor of Goguryeo, hence its name and efforts to recover the former territories of Goguryeo. Wang Geon, the founder of Goryeo, was of Goguryeo descent and traced his ancestry to a noble Goguryeo clan. He made Kaesong, his hometown, the capital.

During this period, laws were codified and a civil service system was introduced. Buddhism flourished and spread throughout the peninsula. The development of celadon industries flourished in the 12th and 13th centuries. The publication of the Tripitaka Koreana onto more than 80,000 wooden blocks and the invention of the world's first metal movable type in the 13th century attest to Goryeo's cultural achievements.

Goryeo had to defend frequently against attacks by nomadic empires, especially the Khitans and the Mongols. Goryeo had a hostile relationship with the Khitans, because the Khitan Empire had destroyed Balhae, also a successor state of Goguryeo. In 993, the Khitans, who had established the Liao dynasty in 907, invaded Goryeo, demanding that it make amity with them. Goryeo sent the diplomat Sŏ Hŭi to negotiate, who successfully persuaded the Khitans to let Goryeo expand to the banks of the Amnok (Yalu) River, citing that in the past the land belonged to Goguryeo, the predecessor of Goryeo. During the Goryeo–Khitan War, the Khitan Empire invaded Korea twice more in 1009 and 1018, but was defeated.

After defeating the Khitan Empire, which was the most powerful empire of its time, Goryeo experienced a golden age that lasted a century, during which the Tripitaka Koreana was completed, and there were great developments in printing and publishing, promoting learning and dispersing knowledge on philosophy, literature, religion, and science; by 1100, there were 12 universities that produced famous scholars and scientists.

Goryeo was invaded by the Mongols in seven major campaigns from the 1230s until the 1270s, but was never conquered. Exhausted after decades of fighting, Goryeo sent its crown prince to the Yuan capital to swear allegiance to the Mongols; Kublai Khan accepted, and married one of his daughters to the Korean crown prince, and the dynastic line of Goryeo continued to survive under the overlordship of the Mongol Yuan dynasty as a semi-autonomous vassal state and compulsory ally. The two nations became intertwined for 80 years as all subsequent Korean kings married Mongol princesses, and the last empress of the Yuan dynasty was a Korean princess.

In the 1350s, King Gongmin was free at last to reform the Goryeo government when the Yuan dynasty began to crumble. Gongmin had various problems that needed to be dealt with, which included the removal of pro-Mongol aristocrats and military officials, the question of land holding, and quelling the growing animosity between the Buddhists and Confucian scholars. During this tumultuous period, Goryeo momentarily conquered Liaoyang in 1356, repulsed two large invasions by the Red Turbans in 1359 and 1360, and defeated the final attempt by the Yuan to dominate Goryeo when General Ch'oe Yŏng defeated a Mongol tumen in 1364. During the 1380s, Goryeo turned its attention to the Wokou threat and used naval artillery created by Ch'oe Mu-sŏn to annihilate hundreds of pirate ships.