Rail transport in Spain

Rail transport in Spain operates on four rail gauges and services are operated by a variety of private and public operators. Total railway length in 2020 was 15,489 km (9,953 km electrified). The Spanish high-speed rail network is the longest HSR network in Europe with 3,973 km (2,464 mi) and the second longest in the world, after China's.
Most railways are operated by Renfe; metre and narrow-gauge lines are operated by the Renfe Cercanías AM division. Local publicly-owned operators include Euskotren in the Basque Country, FGC in Catalonia and Serveis Ferroviaris de Mallorca in the Balearic Islands. Private railway operators include Ouigo and Iryo.
It is proposed and planned to build or convert more lines to standard gauge, including some dual gauging of broad-gauge lines, especially where these lines link to France, including platforms to be raised.
Spain is a member of the International Union of Railways (UIC). The UIC Country Code for Spain is 71.
The first railway line in the Iberian Peninsula was built in 1848 between Barcelona and Mataró. In 1851 the Madrid-Aranjuez line was opened. In 1852 the first narrow-gauge line was built; in 1863 a line reached the Portuguese border. By 1864 the Madrid-Irún line had been opened, and the French border reached. In 1900 the first line to be electrified was La Poveda-Madrid.
After the Spanish Civil War, the Spanish railway system was in a state of disrepair due to the damage caused by the conflict. In 1941 RENFE was created by nationalizing the private companies that had built and until then operated the network, leading to a state-owned rail network.
By the 1950s, the Spanish rail network reached its historical maximum of almost 19,000 kilometers. However, from the mid-1950s onward, the network began to shrink due to the exponential increase in private vehicle ownership in Spain. During the Spanish economic miracle of the 1950s and 1960s, the number of private vehicles in Spain increased more than 14 times from the mid-1940s to the mid-1960s. This led to a decline in demand for rail transport and the closure of some rail lines that were no longer profitable. By 1993, almost 8,000 km of rail lines were dismantled.
The last steam locomotive was withdrawn in 1975, and in 1986 the maximum speed on the railways was raised to 160 km/h, and in 1992 the Madrid-Seville high-speed line opened, beginning the process of building a nationwide high-speed network known as AVE (Alta Velocidad España).
The current plans of the Spanish government are to finish the standard-gauge high-speed network by building new sections of track and upgrading and converting to standard gauge the existing line along the Mediterranean coast connecting the ports of Barcelona, Tarragona, Valencia, Cartagena and Almería, to link Madrid with Vigo, Santiago and A Coruña in Galicia, to extend the Madrid-Valladolid line to Burgos and the Basque cities of Bilbao and San Sebastián, and to Hendaye on the French border, as well as to link Madrid with Lisbon and the port of Sines through Badajoz. Former plans by the Popular Party government under Prime Minister Aznar to link all provincial capitals with high-speed rail have been shelved as unrealistic, unaffordable, and contrary to all economic logic as no European funding would be made available for such projects.
Following the opening of the AVE network, the classic Iberian gauge railways have lost importance in inter-city travel, for example, the Madrid–Barcelona railway takes over nine hours to travel between the two cities stopping at every station. With the Madrid–Barcelona high-speed rail line, the longest possible journey is just three hours. This has allowed the conventional lines to increase focus on regional and commuter traffic, along with freight. Some lines, including the Córdoba-Bobadilla section of the classic Córdoba–Málaga railway, have lost passenger traffic completely due to the opening of AVE serving the same destinations.
Many important mainland Spanish towns remain disconnected from the rail network, the largest being Marbella with a population of over 140,000, along with Roquetas de Mar (pop. 96,800), El Ejido (pop. 84,000), Torrevieja (pop. 83,000) and Mijas (pop. 82,000). Other towns and municipalities are not on the national rail network but linked to light rail or metro systems, such as Santa Coloma de Gramanet, Barcelona (pop. 118,000); Chiclana de la Frontera, Cádiz (pop. 83,000); Torrent, Valencia (pop. 83,000); Getxo, Biscay (pop. 78,000); and Benidorm, Alicante (pop. 70,000).
Starting in Franco's regime and continuing into the 1980s, multiple lines of the Spanish rail network were closed. Campaigns for reopening former lines exist, including a reopening the branch to the aforementioned Torrevieja from the Alicante–Murcia main line; the former line from Guadix to Lorca via Baza (which would provide a direct rail link from Murcia to Granada); Plasencia to Salamanca and Gandía to Dénia.
Since 2007 the operation of freight lines was liberalised and has been open to private operators. Renfe was split in two companies (Renfe, a public company that operates freight and passenger lines, and ADIF, a public company that manages the infrastructure for all public and private operators).
In 2020, long-distance passenger lines were likewise opened to private operators. Ouigo España began service on the Madrid–Barcelona route in 2021, joined by Iryo in 2022.
From 1 September to 31 December 2022 Spain has made free train tickets available under certain conditions. A €10 to €20 deposit must be placed and the scheme is only available on multi-trip tickets or season tickets, rather than singles. 16 or more train journeys must be made between the aforementioned dates in order to receive a full refund. The full refund is available on commuter journeys and medium-distance journeys of under 300 km (186 miles). The initiative is being funded through a windfall tax on banks and energy companies that have made profits from interest rates and energy prices. The tax will be introduced in 2023 and is estimated to raise up to €7 billion in two years. Money raised from the tax will also be used to build 12,000 new homes and fund youth scholarship programmes.
High speed rail was first proposed in Spain in the 1980s, joining the Meseta Central and Andalusia. The first line, joining Madrid and Seville, was opened in 1992, in time for the Seville Expo '92. The line was built on standard gauge, and reused segments of the existing Madrid-Ciudad Real line. After that, connections with Barcelona, Valencia, Málaga and Galicia were subsequently opened. The current network is 3,973 km (2,469 mi) in length, the longest in Europe and the second longest in the world, after China.
The network sees a multitude of services, operated by three companies under a multitude of brands. Renfe operates services under the AVE brand for high speed long distance services, AVANT for high-speed mid distance, and ALVIA and Euromed for services that change gauges. The French operator SNCF runs international services under the inOui brand and national services under the Ouigo low-cost brand. Iryo operates several high speed services.
The current network is divided into many lines, which mostly branch out of Madrid:
Except for the Mediterranean and Cantabrian-Mediterranean corridors, all lines start from the two Madrid terminals, Atocha and Chamartin, which are connected by a crosstown tunnel.
The high speed network not only sees purely high-speed trains, as Alvia and Euromed services use gauge-changing rolling stock to be able to reach destinations not in the high speed network. As such, cities like San Sebastian and Bilbao in the Basque country, Gijón and Oviedo in Asturias or Pamplona in Navarre see services running on the high speed network for some stretches.
In Spain there is an extensive 1,250 km (780 mi) system of metre-gauge railways.
Andorra has no rail system (the closest station to Andorra is the French station of Andorre-L'Hospitalet station). The British overseas territory of Gibraltar also lacks a rail system.
Spain has railway connections with France and Portugal. Neither Andorra nor the British Overseas territory of Gibraltar have rail systems, though a link to Andorra has been proposed. The Moroccan rail network is neither connected to the Iberian Peninsula (although an undersea tunnel has been proposed) nor to the Spanish autonomous cities of Melilla and Ceuta (respectively closest to the Moroccan stations of Beni Ansar and Tangier-Med).
Trains can cross the border at Irún–Hendaye and at Portbou–Cerbère on the conventional network, and through the Perthus tunnel on high speed trains.
The Irún–Hendaye crossing is at the western end of the Pyrenees, and has two rail lines crossing the Bidasoa River. On the mainline, trains can cross the border but have to change gauge or transfer their freight or passengers to other trains. The narrow-gauge Lezama to Hendaye line, operated by Euskotren, does cross the border, though it only has one stop on the French side next to the Hendaye mainline railway station. A high-speed rail crossing is under construction from both the Spanish and French sides, which will also allow for freight rail without changing gauge, as part of the Basque Y.
The Portbou–Cerbère crossing lies on the eastern end of the border, on the Mediterranean coast. Trains also require a transfer at either the Portbou or Cerbère stations, which are separated by a short tunnel. Both SCNF TER services and Renfe Regional and MD services cross the border.
The Perthus tunnel is the only current border crossing that doesn't break gauge. It connects the Spanish and French high speed networks, as both operate on standard gauge. It sees both passenger and cargo transit. Both SNCF and RENFE AVE trains cross the tunnel, connecting Madrid and Barcelona with Marseille, Lyon, Paris and destinations in between. With the future opening of the Montpellier to Perpignan high speed line, trains will be able to run the whole route on high speed tracks.
There used to be a third crossing at the Canfranc International railway station. The line connected Zaragoza with Pau, though it was closed in 1970 after a bridge collapse on the French side of the border. The Canfranc station currently sees two trains a day, but there are ongoing studies to reopen the line.
As both the Portuguese and Spanish networks run on Iberian gauge, trains do not need to change gauge to cross the border. There are currently three crossings in operation, though only one train serves multiple destinations on both sides of the border.
The crossings are:
Two new crossings for high speed trains are in different stages of development: a new Vigo-Porto crossing, which will join the Spanish Atlantic Axis with the Lisbon–Porto high-speed line and the new Lisbon-Madrid high speed rail line.
There have been proposals to build a new southern crossing over the Guadiana river, between the cities of Ayamonte and Vila Real de Santo António. Trains used to reach the river on both sides, though there was no river crossing. The Spanish line from Gibraleón to Ayamonte was closed in 1987.
In 2004, the Spanish government adopted a new strategic plan for transportation through 2020 called the PEIT (Strategic Plan for Infrastructures and Transport). This detailed rail subsidies of around €9.3 billion annually on average from 2005-2020. In 2010, it rolled out a two-year plan to invest an extra €11 billion each year for two years, as a part of a financial stimulus in response to the global downturn. In 2015, the federal budget for the railways was €5.1 billion.