The first railway in Yunnan was the narrow gauge Yunnan–Vietnam Railway built by France from 1904 to 1910 to connect Kunming with Vietnam, then a French colony. In Yunnan, the Chinese section of this railway is known as the Yunnan-Hekou Railway and the line gave Yunnan access to the seaport at Haiphong. During the Second World War, Britain and the United States began building a railway from Yunnan to Burma but abandoned the effort due to Japanese advance.
Due in part to difficult terrain both locally and in surrounding provinces and the shortage of capital for rail construction, Yunnan remained outside of China's domestic rail network until 1966 when the Guiyang–Kunming Railway was completed. The line would not enter into operation until 1970, the same year that the Chengdu-Kunming was completed. The Nanning–Kunming Railway to Guangxi was completed in 1997, followed by the Neijiang–Kunming Railway in 2001. The Panxi Railway, originally built in 1975 to draw coal from neighboring Guizhou, was electrified in 2001 and adds to eastern Yunnan's outbound rail transport capacity.
Within the province, the Kunming–Yuxi, opened in 1993, and the Guangtong–Dali, opened in 1998, expanded the rail network to southern and western Yunnan, respectively. The Dali–Lijiang Railway, opened in 2010, brought rail service to northwestern Yunnan. That line is planned to be extended further north to Xamgyi'nyilha County.
The province is extending the railway network to neighboring countries in Southeast Asia. From Yuxi, the Yuxi–Mengzi Railway, built from 2005 to 2013, and the Mengzi–Hekou Railway, under construction since 2008, form eda standard gauge railway connection with Vietnam.
The Dali–Ruili Railway, under construction since May 2011, will rail service to the border with Myanmar. Also under planning is a rail line from Yuxi to Mohan, in Xishuangbana Prefecture, on the border with Laos. This line could be extended further south to Thailand, Malaysia and Singapore.