By the Neolithic period, human settlements existed in the area of Lake Dian, close to modern-day Kunming, Yunnan's capital.
The local people used bronze tools, plows and kept a variety of livestock, including cattle, horses, sheep, goats, pigs and dogs.
Chinese dynasties of Jin, Liu Song, Southern Qi and Northern Zhou maintain their rules around the commandery in the Kunming area.
Southwest Yunnan and the eastern rugged, mountainous areas were still enjoying relative independence, ruled by tribal kings and chieftains with little Chinese influence.
In 649 AD the chieftain of the Yi Mengshe tribe, Xinuluo (細奴邏), founded a kingdom (大蒙國; Dàméngguó) in the area of Lake Erhai.
Bolstered by these successes, Nanzhao expanded rapidly, first into Burma, then into the rest of Yunnan, down into northern Laos and Thailand, and finally, north into Sichuan.
The central government allowed the general Mu Ying, foster son of dynastic founder Zhu Yuanzhang, to set up a hereditary feudatory system in the province.
The rebels in western Yunnan under the leadership of Du Wenxiu became the major military and political center of opposition to the Qing government.
The rebellion successfully captured the city of Dali, which became the base for the rebels' operations, and they declared themselves a separate political entity from China.
The rebels identified their nation as Pingnan Guo (平南国; 'Pacified Southern Kingdom') and Du Wenxiu was styled Qa´id Jami al-Muslimin ('Leader of the Community of Muslims'), but is usually referred to in foreign sources as Sultan, and ruled 1856 – 26 December 1872.
For a period of perhaps ten to fifteen years following the collapse of the Panthay Rebellion, the province's Hui minority was widely discriminated against by the victorious Qing, especially in the western frontier districts contiguous with Burma.
In Second Sino-Japanese War, Yunnan served as, among other things, a home base for the Flying Tigers and a refuge for people, especially university faculty and students, from the east.
In these extraordinary wartime circumstances for eight years, staff, professors and students had to survive and operate in makeshift quarters that were subject to sporadic bombing campaigns by Japan.
[citation needed] The establishment of the PRC brought gradual but definite consolidation to China's southwestern borders, solidifying what were previously murky claims to various regions.
In fact, between 1904 and 1909 the French had built the 885 km (550 mi)long Sino-Vietnamese Railway which ran from Hanoi to Kunming via Hekou, with an offshoot to Gejiu.
The English tried to match the French effort with the Yunnan–Burma Railway, but failed to complete it prior to the outbreak of war, with the project ultimately abandoned.
The PRC also saw a bitter Sino-Vietnamese War fought along Yunnan's south eastern border, which was properly demarcated only on 23 February 2009,[5] with renewed agreements taking effect as late as 14 July 2010.
This is illustrated by Otto E. Ehlers' (1855–1895) account of his walk from Rangoon to Jinghong, recording upon his arrival that the annual Chinese tribute mission from northerly Simao was in town and, whilst they were happy to allow him to stay on the south of the Mekong river, he was not to be lent assistance in crossing over.