The Edinburgh, Loanhead and Roslin Railway was a railway line south of Edinburgh, Scotland, built primarily to serve mineral workings, although passenger trains were operated. It is also known as the Glencorse Branch of the North British Railway. It opened from a junction at Millerhill on the Waverley Route, to Roslin in 1874 and was extended to a location near Penicuik to serve Glencorse Barracks and a colliery in 1877 and to Penicuik Gas Works in 1878.
Bus services substantially eroded the passenger carryings on the line, and passenger trains ceased in 1933. There was some revival in colliery activity after World War II but most of the traffic had ceased in 1969 and the line finally closed completely in 1989.