The railway was built under the French colonial rule. The first section from Lạng Sơn to Bắc Giang was built between 1890 and 1894, originally adopting a 600 mm narrow gauge. Under the rule of governor Paul Doumer the railway was converted to metre gauge and extended to Hanoi (in 1900), and to Đồng Đăng (in 1902).[2][3][4] In 1954 the line was renovated with help from China, and connected to the Chinese Hunan–Guangxi railway.[5] During the Vietnam war, the PLA Railway Corps repaired the railway from wartime damage and converted it to the present dual gauge.[6][7]
On 1 January 2009 through passenger service between Nanning (China) and Gia Lâm (Hanoi) started.[8]