information:filtering, quality:correction, linguistic:translation
Ming and Qing dynasties

In the 14th century, Kunming was retaken from Khan Mongolian control when the Ming dynasty defeated the Yuan dynasty, later building a wall surrounding present-day Kunming. 300 years later, Ming General Wu Sangui defected to Manchu invaders and held the city until his death in 1678, long after the rest of China had fallen under Manchu rule. During the beginning of Qing rule, the entirety of Yunnan and Guizhou were ruled from Kunming and Wu. During the Revolt of the Three Feudatories, the seat of Wu's newly declared Zhou dynasty was moved to Hengzhou, Hunan. Later in 1678 when Wu died, his grandson Wu Shifan resisted the Qing for two more months before committing suicide, thereby reverting control of the city back into Qing hands. During the Ming and Qing dynasties, it was the seat of the superior prefecture of Yunnan.

The area was first dubbed Kunming in the period towards the decline of the Yuan dynasty and later still in 1832, the beginnings of a real city were acknowledged within the city walls and significant structures within their confines. Founding of the city can therefore be said to have been a predominantly 19th century affair. It was also in this century that the city grew to become the major market and transport centre for the region. Many of the city's inhabitants were displaced as a result of the 1833 Kunming earthquake.

The rebel leader Du Wenxiu, the Muslim Han Sultan of Dali, attacked and besieged the city several times between 1858 and 1868. A great part of the city's wealth did not survive the 1856 Panthay Rebellion, when most of the Buddhist sites in the capital were badly damaged, converted to mosques or razed. Decades later, Kunming began to be influenced by the West, especially from the French Empire. In the 1890s, an uprising against working conditions on the Kunming–Haiphong rail line saw many laborers executed after France shipped in weapons to suppress the revolt. The meter-gauge rail line, only completed by around 1911, was designed by the French so that they could tap Yunnan's mineral resources for their colonies in Indochina.

Kunming was a communications center in early times and a junction of two major trading routes, one westward via Dali and Tengchong County into Myanmar, the other southward through Mengzi County to the Red River in Indochina. Eastward, a difficult mountain route led to Guiyang in Guizhou province and thence to Hunan province. To the northeast was a well-established trade trail to Yibin in Sichuan province on the Yangtze River. But these trails were all extremely difficult, passable only by mule trains or pack-carrying porters.