Beginning in 1170, the government of Goryeo was de facto controlled by a succession of powerful families from the warrior class, most notably the Choe family, in a military dictatorship akin to a "shogunate". During the military rule, Goryeo resisted invasions by the Mongol Empire for almost 30 years, until the ruling head of the Choe family was assassinated in 1258 by opponents in the court, after which authority was restored to the monarchy and peace was made with the Mongols; however, power struggles continued in the court and military rule did not end until 1270. From that point on, Goryeo became a semi-autonomous "son-in-law nation" of the Mongol-led Yuan dynasty through royal intermarriage and blood ties. Independence was regained during the reign of Gongmin in the mid 14th century, and afterward Generals Choe Yeong and Yi Seong-gye rose to prominence with victories over invading Red Turban armies from the north and Wokou marauders from the south. In 1388, Yi Seong-gye was sent to invade the Ming dynasty at Liaodong, but he turned his forces around and defeated Choe Yeong in a "coup d'état"; in 1392, he replaced Goryeo with the new state of Joseon, bringing an end to 474 years of Goryeo rule on the Korean Peninsula.