The military use of railways derives from their ability to move troops or materiel rapidly and, less usually, on their use as a platform for military systems, like very large railroad guns and armoured trains, in their own right. Railways have been employed for military purposes in wartime since the Revolutions of 1848. Improvements in other forms of transport have rendered railways less important to the military since the end of World War II and the Cold War, although they are still employed for the transport of armoured vehicles to and from exercises or the mass transport of vehicles to a theatre of operations. The US Air Force developed the Peacekeeper Rail Garrison mobile ICBM in the 1980s, but it never reached operational status. Railways have played an important role in the logistics of the 2022 Russian invasion of Ukraine.
Due to the expense and time required to build specifically military railway networks, military use of railways is usually based on a pre-existing civilian railway network rather than a military-owned one. However, specialized military types of rolling stock have frequently been used. Military railway is usually built and operated by railway troops. Sometimes so called strategic railways are built where civilian considerations would not justify a line or not one built to those standards.
The Kingdom of Prussia's VI Corps, some 12,000 men and their guns, horses, ammunition and other material, was transported on two railway lines to Kraków in 1846. The Prussian Army used railways to move its forces during the First Schleswig War in 1849–1851. Three Prussian battalions were deployed by rail to crush the 1849 May Uprising in Dresden. The first Prussian regulations for transport of troops on state railways were issued in 1856.
In 1849, an Imperial Russian corps with all of its equipment, was moved by rail from Poland to Göding in Moravia to link up with the Austrian army during the Hungarian Revolution of 1848.
Military railways were used to establish a reliable supply to British Army troops besieging the city of Sevastopol from Balaklava during the severe winter of 1855 in the Crimean War. The Grand Crimean Central Railway was just long, and was purpose built.
During the Second Italian War of Independence in 1859, the French Army moved 130,000 soldiers to northern Italy by rail. The Imperial Guard Corps from Paris and two corps from Lyon were sent to Toulon via rail, from where a total of 70,000 men were shipped to Genoa. The French I Corps was then ferried from Genoa to Novi by rail. Another two French corps were transported by rail to Savoy, where they crossed the Alps and boarded trains to Turin. To improve Piedmont's railway system, the French Navy shipped locomotives to Genoa. A French siege train was shipped from Marseille and Toulon to Genoa, from where it was moved by rail to Lombardy for use against Mantua in late June.
The American Civil War in 1861–1865 was the first large war in which railroads were both a major tool and a major target of military action. A few railroads were custom built:
In 1867 during the Paraguayan War some ironclad vessels of the Brazilian navy became trapped on the River Paraguay between the enemy Paraguayan forts of Curupaty and Humaitá. To keep them supplied with fuel, ammunition and provisions the Brazilian ministry of marine ordered an emergency military railway to be built through the almost impenetrable coastal region of the Chaco. The sleepers of this line almost floated over the boggy ground. This supply line was known as the Affonso Celso, and sustained the ironclads in their precarious position for six months, until they were able to dash past the Fortress of Humaitá in an incident known as the Passage of Humaitá.
The Trans-Siberian Railway (Транссибирская железнодорожная магистраль - Транссиб), before 1917 was called the Great Siberian Route (Великий Сибирский Путь). First construction begun on 19 May (31 May) 1891. It was used in the Russo-Japanese War and Russian Civil War.
In 1896-98 during the Mahdist War, Kitchener built the Sudan Military Railroadextending the Egyptian railways into the Sudan.
The early phase of World War I was influenced to a large degree by the speed of military mobilization via railways. The German Schlieffen Plan relied on an extensive network of strategic railways to allow crushing France before Russia could mobilize. However, ultimately this failed as Russia mobilized more quickly than Germany had anticipated, and Germany's offensive on the Western front ground down to stalemate and trench warfare. The resulting unprecedented heavy use of artillery required transport on an unprecedented scale, and narrow gauge military trench railways were quickly built to service the Western Front for both sides.
German military transport was mostly dependent on trains and horses in World War II. Railway sabotage during World War II was among the difficulties. Leaders also used military trains, for example Adolf Hitler's Amerika and Hermann Goering's Asien. Trains were protected by railcars armed with anti aircraft guns or flak waggon.
German bombing of Polish railways contributed greatly to the swift success of the 1939 invasion of Poland. In turn, losses due to air attacks on Deutsche Reichsbahn in 1944 severely handicapped German logistics.
Japan built several railways for military purposes, notably the Burma-Siam Railway, known as the Death Railway because of the number of Allied prisoners-of-war and Asian labourers who died to construct it.
The existing Northeast Indian Railways were expanded by the Americans to supply China via the Ledo Road. Railway lines were also constructed by the Allies in the Suez Canal area.