When Ming armies closed in during 1368, the last Yuan emperor, Toghon Temür, left the capital Dadu (present-day Beijing) and withdrew north to the steppe. The state did not end; the whole court simply moved, and so people called it the Northern Yuan — the Yuan court in the north. It still called itself the Great Yuan, and still regarded China as its own to win back.
Toghon Temür fell back through Shangdu to Yingchang, where he died in 1370. The court then centred itself on Karakorum, the old capital from the days of Genghis Khan. Back on the grasslands the Northern Yuan proved anything but easy prey. When the Ming sent three armies deep into the steppe in 1372, the Northern Yuan commander Köke Temür gave ground, drew them far into the desert, and beat them badly. After that defeat the Ming gave up the idea of conquering the steppe, rebuilt the Great Wall, and settled for guarding the frontier.
The turning point came in 1388, when the Ming general Lan Yu surprised and shattered the court at Buir Lake. Khan Tögüs Temür escaped the battlefield but was killed soon after by a rival power among the Mongols. From then on the line of khans descended from Kublai was broken, and the Mongols split into the Tatars in the east and the Oirats in the west, each contesting the title.
A story Mongolians still love to tell comes from this era. In the late 15th century a woman named Mandukhai Khatun took a seven-year-old orphan boy, Batu Möngke, under her protection, had him proclaimed khan, put on armour herself, and led the armies that gathered the scattered Mongol tribes back together. In the telling, she was thrown from her horse in battle and simply climbed back on and fought on. The boy grew up to be Dayan Khan, who reunited the Mongols.
The Northern Yuan lived alongside the Ming for more than two hundred years, sometimes fighting, sometimes trading horses for silk. In 1449 the Oirat leader Esen went so far as to capture a Ming emperor. The line of Mongol khans ran until 1635, when the son of the last khan handed the imperial seal to the Manchus.