The Mongols defeated whichever dynasty, north or south, they came up against and by 1279 their leader Kublai Khan became the first foreigner to rule all of the country as Emperor of the Mongol (Yuan) dynasty. It would be almost ninety years before the Han took charge of their own affairs with the establishment of the Ming dynasty.