Rail transport in Ukraine is a major transport mode in Ukraine. Most railway infrastructure in Ukraine is owned by the government of Ukraine through Ukrzaliznytsia (Public JSC 'Ukrainian Railways'), a joint-stock company which has a de facto country-wide monopoly on passenger and freight transport by rail.

The first railway tracks were constructed in present-day western Ukraine by Austria-Hungary, but most lines were built under the Russian Empire or the Soviet Union, resulting in a track web dominated by 1520 mm gauge railways. Part of the rail network in eastern Ukraine was privatized in the late 1990s, creating the biggest private railway company in the country, Lemtrans, which focuses on freight transport. Since the outbreak of the Russo-Ukrainian War in 2014, intensified by the February 2022 full-scale Russian invasion of Ukraine, major parts of the Ukrainian rail network have been occupied by Russia-aligned military forces, while the Ukrainian government and Ukrzaliznytsia have undertaken considerable efforts to repair and transform the network for better vital logistical connections with the European Union (which mostly has standard-gauge railways) and Moldova.

History Before Ukrainian independence Early railway systems

In January 1855, during the Siege of Sevastopol, part of the wider Crimean War, construction of a railway line between Balaklava Bay and British Army positions around Sevastopol started. By April, 240 tons of freight were transported daily over the route. It was the first railway line in the territory of modern Ukraine.

In Austria-Hungary

The first regular railway line in the lands of modern Ukraine was constructed as part of the Galician Railway between 1859 and 1861, connecting Przemyśl and Lviv. On 4 November 1861, the first passenger train arrived to Lviv Railway Station. In the following years, with the support of prince Leon Sapieha, a line connecting Lviv with Chernivtsi, the capital of Bukovina was constructed. Inaugurated on 1 September 1866, it would be later continued towards Iasi and Suceava. In 1869 another line connecting Lviv with Brody and the Russian border was opened; four years later, railway transit to the Russian side became possible after the opening of Radyvyliv station. On 28 December 1870 Lviv was connected to Ternopil via Krasne railway station, and next year the line reached Pidvolochysk and Volochysk, establishing a link to Odesa.

During the early 1870s, construction started on a railway line across the Carpathian Mountains, connecting Lviv and Pest via the Volovets Pass. In September 1873, a railway link between Lviv and Stryi was opened, and in May 1875 the Galician capital received connection with Stanislaviv. However, construction on the southern part of the line, passing across the Carpathians, was hindered by financial and political issues. Finally, in 1883 the Austrian government accepted an obligation to build the section of the line between Stryi and Beskyd, and next year Hungarian authorities agreed to construct the section from Mukachevo, with both segments of the route meeting at the station of Lavochne. Five railway tunnels and several bridges were built between Volovets and Beskyd. On 4 April 1887 the Carpathian route was finally inaugurated.

In 1893 the construction of another line across the Carpathians started in order to connect Stanislaviv with Hungarian territory. Led by Italian specialists, the project envisioned the railway to cross the Prut valley in the areas of Deliatyn, Mykulychyn, Tatariv and Vorokhta; on the southern side of the mountains, it was to run through Körösmezö and reach Bocsko. 9 bridges and three tunnels were built along the route, which was inaugurated in 1898. In 1901 the construction of a railway between Lviv and Sambir started along the Dniester river. From Sambir, the line was continued to Turka, crossing the Carpathian valleys over two bridges. In 1905 a connection between Sianky and Uzhok was established.

In general, Ukrainian lands ruled by Austria-Hungary had a much denser railway network compared to Russian-ruled Ukraine. Between 1890 and 1912 the length of passenger railways in Galicia increased from 1,375 to 2,325 kilometers. The total length of the railway system in Galicia, Bukovina and Transcarpathia by 1914 reached 3,700 kilometers.

In the Russian Empire

The first railway line in Ukrainian lands under the rule of the Russian Empire was opened in 1865 and connected Odesa with Balta. In 1868-1870 the route was expanded to Kremenchuk and Kyiv, establishing a link to Moscow. The main purpose of railway construction during that period was the export of grain and other agricultural products. Later, railways also became important for the transportation of coal and ore.

During the 1870s, railway lines connected Moscow with Kharkiv, Lozova, Sevastopol and Mykolaiv. In 1873, a railway line between Kivertsi, Kovel and Brest was inaugurated, connecting Odesa and Kyiv with the Baltics. Another important route connected Romny with Libava (now Liepāja, Latvia), contributing to the export of Ukrainian grain over the Baltics. In 1884 a railway line connected the Donbas with Kryvyi Rih. As of 1914, the total length of railways in Ukrainian parts of the Russian Empire reached 16,000 kilometers.

World War I and Interwar period

During the First World War, a number of new railway lines were established in frontline areas due to strategic considerations. Revolution and Ukrainian War of Independence led to chaotic conditions on the railways, which started to retain their functions only during the 1920s. Authorities of the Ukrainian People's Republic and the Ukrainian State dedicated special attention to railway infrastructure, and several prominent political figures of Ukraine during that time, such as Vsevolod Holubovych and Borys Butenko, were railway engineers by profession. After the establishment of the Directorate of Ukraine, its leader Symon Petliura issued a decree, according to which all railway workers in Ukraine received an equal status to military servicemen.

Following the Polish-Ukrainian War, Galician railways became the property of Polish State Railways, meanwhile railways in Bukovina came under Romanian jurisdiction. Despite this, the line between Lviv and Chernivtsi preserved its great importance for international trade during the Interwar period. In Soviet Ukraine, around 4,000 kilometers of railways were constructed between the wars, chiefly in the Donbas, Dnipro and Kryvbas industrial regions. Important routes established during that time connected Kharkiv, Dnipropetrovsk and Kherson, and Krasnyi Lyman with Kupiansk. Another major line created a railway link between Chernihiv and Ovruch in the Polesia. As a result of modernization and expansion of the network, between 1913 and 1940 transportation of freight increased from 61,7 to 200 millions of tons, and the number of railway passengers grew from 49 to 243 million.

World War II and aftermath

During the Second World War, Ukraine's railways suffered severe damage, with over 9,200 kilometers of tracks and over 2,000 bridges being demolished. By 1948, the railway system had largely restored its function, but many railway lines, especially in Galicia, continued to be disused. Electrification of railways progressed slowly. During the postwar period, Ukrainian railways were subordinated to the all-Union ministry in Moscow and administratively subdivided into several directorates.

Notable educational establishments which produced railway specialists functioned in Kharkiv and Dnipropetrovsk, and large train factories were active in Luhansk (Luhanskteplovoz), Kharkiv, Kremenchuk (Kryukiv Railway Car Building Works), Dniprodzerzhynsk and Darnytsia.

Early Ukrainian independence era (1991–2014)

On 24 September 1991, following the resolution of the Verkhovna Rada (Ukraine's parliament) on separation from the Soviet Union, all railroad administration was temporarily passed to the South-Western Railways. According to the resolution, all assets located within the borders of the former Ukrainian SSR became property of Ukraine. To improve efficiency a special centralized administration was created. On 14 December 1991 the Cabinet of Ministers of Ukraine issued declaration No. 356 "In creation of the State Administration of Railroad Transportation in Ukraine" which proclaimed Ukrzaliznytsia a government body in administration railroad transportation uniting the six state railroad companies.

Russo-Ukrainian War (2014–present) War in Donbas era (2014–2022) At the outbreak of the Russo-Ukrainian War in 2014, the Russian Federation annexed Crimea and Sevastopol, while large parts of Donetsk and Luhansk Oblasts were seized by Russia-backed separatists, severely disrupting rail transport throughout southern and eastern Ukraine.

As of 2015 the Ukrainian government transformed the railways into a public joint-stock company named Ukrainian Railways ().Ukrzaliznytsia officially becomes joint-stock company, UNIAN (21 October 2015)http://en.interfax.com.ua/news/economic/299132.html

Full-scale Russian invasion (early 2022 phase) The 2022 Russian invasion of Ukraine showed the crucial role of railways in both civilian and military logistics in the area. Given the lack of roads passable during rasputitsa and the Russian lack of vehicles capable of off-road operation, logistics relied heavily on rail transport. Railway nodes became an important target of Russian attacks to maintain their own supply lines and disrupt those of Ukraine. At the same time, Ukraine's exports and imports were shifted even more to rail than in peacetime as Russia captured or cut off many important Black Sea ports that usually handle a large share of Ukraine's external trade. Railways were crucial in transporting refugees and European governments, and state railways organized special trains for humanitarian aid to and from Ukraine. As airports were targets of Russian attacks and/or Ukrainian counter-attacks, trains were also used for diplomatic visits by foreign heads of state and government.

2022 rail freight crisis

Due to the Russian invasion, many of the country's Black Sea ports were blocked, prompting a crisis in the export of agricultural products that were normally shipped. Railway freight has become the most viable alternative, but the Ukrainian railway network has not been able to cope with the demand, mainly because of the railway break-of-gauge between Ukraine's Soviet-era 1520 mm gauge railways and the standard-gauge railway (1435 mm) of states west of its borders has created bottlenecks at transloading stations. On 7 April 2022, Ukrzaliznytsia reported that 10,320 wagons (about half of the total) were waiting at the Ustyluh (Izov)–Hrubieszów border crossing on the Linia Hutnicza Szerokotorowa line, the main railway connection between Ukraine and Poland and the longest 1,520 mm gauge railway of Poland.

Efforts to quickly increase rail freight capacity have been launched, including construction of new large transloading stations near Mostyska and elsewhere, mainly in Poland. As of 12 April 2022, the Mostyka station was planned to be completed by June 2022, with a transloading capacity of 50,000 metric tonnes of grain per month by July, and 100,000 tonnes by September. Additional challenges included the need to increase the number of wagons, appropriate permits to let Ukrainian wagons ride in EU territory, and to increase the capacity of EU ports (such as Gdańsk, Hamburg and Rotterdam) that would have to take over the shipping role of the blocked Black Sea ports.

Some railway stations have been damaged due to the war.

Restoration and modernisation (late 2022–present)