In 1860, when the stretch of the St. Petersburg–Warsaw railroad to Daugavpils (then Dvinsk) was completed, the first trains rolled over Latvian land and Robert Stephenson's factory produced the first steam engines for use on the Riga–Daugavpils line. The construction of the Riga–Daugavpils railway was initiated by the Riga Stock Exchange with the aim to develop port facilities and manufacturing in Riga. This railway was opened on 12 September 1861 and thus the foundation for further expansion of the rail network in Latvia was laid.
The total length of railroad built by the beginning of World War I was 1 941 kilometres. Most of the lines were connected to ports. The most important routes led from Riga to Orel in Russia, from Liepāja to Romny in Ukraine, and from Ventspils to Moscow. The Riga–Mažeikiai, Riga–Tukums, and Riga–Pskov lines were likewise important. As late as the turn of the 20th century, the train was the only mechanised land transport.
During the years of World War I, additional 822 km of rail were laid, primarily as narrow-gauge railroads used for the war effort. All broad-gauge railroads in Kurzeme and Zemgale were rebuilt to match the width of the railroads in Western Europe (1 435 mm) but in Vidzeme and Latgale, the width of the rail remained unchanged (1 524 mm). After the war, it allowed passengers to travel from Riga directly to Western European countries and also to Estonia and Russia.
As the Latvian Railroad Administration began work in 1919, the railroads and bridges destroyed during the war were repaired and the extensive railroad system put to order. In the years 1925–1929, the Liepāja–Glūda line started operating, joined in subsequent years by Rīga–Rūjiena, Rīga–Ērgļi, Madona–Lubāna, Liepāja–Kuldīga, Sita–Rēzekne, Krustpils–Jēkabpils, Pakalnieši–Kūdupe, Ventspils–Dundaga and other lines. In 1938, the total length of serviceable railroads reached 3 350 km; in terms of density of the railroad network to the number of population Latvia was second in Europe, becoming a true railway superpower. Passenger and cargo cars, engines and motorcars, alarm and communication systems, rails and other railroad equipment were all built here. The speed of passenger trains increased, reaching 100 km per hour on many lines. Over 120 new and spacious railway station premises were built as were many bridges.