# 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.

## History

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 network

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:
* Atlantic Corridor, which connects Madrid Chamartín station with most of the northeastern part of the peninsula. The first lines in this corridor were opened in 2011. This corridor includes lines to Galicia, Asturias and Castile and Leon. It's currently undergoing extensions to Cantabria through Palencia and to the Basque country through Burgos, both expected to open by 2027.
* Northeast corridor, which includes the Madrid–Barcelona–French border line and the Zaragoza–Huesca branch. The Madrid-Zaragoza-Lleida segment opened in 2003, and the rest of the line was opened in stages from 2006 to 2013, when it reached the border.
* East corridor, connecting Madrid with Valencia and Alicante through Cuenca and Albacete. First opened in 2010, with the last segment opening in 2013.
* Mediterranean corridor, mostly under construction. It's part of the larger TEN-T Mediterranean corridor, and it runs mostly parallel to the Mediterranean coast from the port of Algeciras to the French border at Figueres. Currently, only two stretches are opened: Castelló de la Plana to Valencia in a mixed gauge configuration and Alicante to Murcia. The rest of the line is planned to open in several stages from 2025 onwards.
* Cantabrian-Mediterranean corridor. Roughly parallel to the Ebro river, it will eventually join the Basque Country and Cantabria with the Mediterranean coast, joining the Madrid–Barcelona line at Zaragoza.
* South corridor, which includes all lines connecting Madrid with Andalusia. This includes the Madrid–Seville line, the Córdoba–Antequera–Málaga line, the Antequera–Granada, the Seville-Cadiz line and the future Antequera–Seville line, which will connect Malaga and Granada with Seville. It also includes a spur line to Toledo.
* The Southwest corridor, still mostly under construction, which will eventually move passengers between Madrid, Lisbon and cities in between, and which will take over the spur from Toledo as the starting point of the mainline.
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.

## Operators

* Renfe is a state-owned company which operates freight and passenger trains on the 1,668 mm (5 ft 5+21⁄32 in) "Iberian gauge", 1,435 mm (4 ft 8+1⁄2 in) standard gauge and 1,000 mm (3 ft 3+3⁄8 in) metre gauge rail networks of the Spanish nationalized infrastructure company ADIF (Spanish: Administrador de Infraestructuras Ferroviarias). Both were formed from the break-up of the former national carrier Renfe (Spanish: Red Nacional de los Ferrocarriles Españoles, "Spanish National Railway Network") and subsequently of FEVE (Spanish: Ferrocarriles Españoles de Vía Estrecha, "Narrow-Gauge Spanish Railways").
** Zamora station
** Toledo station
** Atocha station, Madrid
** Estació del Nord, Valencia
** Lleida-Pirineus station
* Ouigo España is a subsidiary of the French company SNCF that operates long-range passenger trains on high-speed lines.
* Iryo is the brand of ILSA, a Spanish-Italian company formed by Air Nostrum and Trenitalia that also operates long-range passenger trains on high-speed lines. Renfe, OUIGO and Iryo have all competed on several high-speed lines owned by ADIF after the liberalization of long-range passenger rail transport.
* Euskotren (Basque: Eusko Trenbideak, Spanish: Ferrocarriles Vascos, "Basque Railways") operates trains on part of the narrow-gauge railway network in the Basque Country.
* FGC (Catalan: Ferrocarrils de la Generalitat de Catalunya, "Catalan Government Railways") operates several unconnected lines in Catalonia. It operates 140 km (87 mi) of narrow-gauge, 42 km (26 mi) of standard-gauge, and 89 km (55 mi) of Iberian-gauge routes, two metre-gauge rack railways and four funicular railways.
* FGV (Valencian: Ferrocarrils de la Generalitat Valenciana, "Valencian Government Railways") operates several metre-gauge lines in the Valencian Community.
* FS (Catalan: Ferrocarril de Sóller, "Sóller Railways") operates an electrified 914 mm (3 ft) narrow-gauge railway on the Spanish island of Majorca between the towns of Palma and Sóller.
* SFM (Catalan: Serveis Ferroviaris de Mallorca, "Majorcan Railway Servicies") operates the 1,000 mm (3 ft 3+3⁄8 in) metre-gauge railway network on the Spanish island of Majorca.
* Acciona Rail Services, a subsidiary of Acciona, operates a coal cargo line between Asturias and the province of León.
* COMSA Rail Transport, a subsidiary of COMSA, operates a cargo line from the Port of Gijón to Valladolid.
* Continental Rail is dedicated to bringing materials into the gorges of the high-speed lines in progress.

## Lines
### Conventional Iberian-gauge lines

* Alcázar de San Juan–Cádiz railway
* Algeciras-Bobadilla railway
* Barcelona–Cerbère railway
* Casetas–Bilbao railway
* Chinchilla–Cartagena railway
* Córdoba–Málaga railway
* León–A Coruña railway
* Linares Baeza–Almería railway
* Madrid–Barcelona railway
* Madrid−Aranda−Burgos (mostly non-operational)
* Madrid–Hendaye railway
* Madrid–Valencia railway
* Madrid−Valencia de Alcántara railway
* Valencia−Sant Vicenç de Calders railway
* Venta de Baños–Gijón railway
* Huelva–Seville railway

### High-speed standard-gauge lines
#### Operational

* Antequera–Granada high-speed rail line
* Atlantic Axis high-speed rail line
* Madrid–Barcelona high-speed rail line
* Perpignan–Barcelona high-speed rail line (Figueres-Barcelona section)
* Madrid–Asturias high-speed rail line
* Madrid–Levante high-speed rail network (Madrid–Valencia, Madrid–Alicante)
* Madrid–Málaga high-speed rail line
* Madrid–Seville high-speed rail line
* Madrid–Galicia high-speed rail line

### Narrow-gauge lines

In Spain there is an extensive 1,250 km (780 mi) system of metre-gauge railways.

### Metro/light-rail systems

* Alicante (Alicante Tram)
* Barcelona (Barcelona Metro/Tram)
* Bilbao (Bilbao Metro/Tram)
* Cádiz (Cádiz Bay tram-train)
* A Coruña. Started services in 1997 but was dismantled in 2011.
* Granada (Granada Metro).
* Jaén (Jaén Tram) built in 2011 but without service for political reasons.
* Madrid (Madrid Metro)
* Málaga (Málaga Metro)
* Murcia (Murcia tram)
* Palma (Palma Metro)
* Parla (Parla Tram)
* Santa Cruz de Tenerife (Tenerife Tram)
* San Sebastián (San Sebastián Metro)
* Seville (Seville Metro/Tram)
* Valencia (Metrovalencia)
* Vélez-Málaga (Vélez-Málaga Tram) opened in 2006, closed 2012
* Vitoria-Gasteiz (Vitoria-Gasteiz tram)
* Zaragoza (Zaragoza Tram)

## Rail links with adjacent countries

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).

### France

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.

### Portugal

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:
* Tuy–Valença, over the Minho river. It sees two passenger trains a day as part of the Tren Celta route, and two regional trains between Vigo and Valença. The Tren Celta runs between Vigo and Porto, and is operated by the Portuguese national carrier CP.
* Barca d'Alva–La Fuente de San Esteban, closed in 1985.
* Fuentes de Oñoro–Vilar Formoso, currently in operation but without passenger service. The Surexpreso train, which joined Paris with Hendaye and Madrid through this crossing, was suspended in March 2020.
* Valencia de Alcántara–Beira Alta, which saw the Trenhotel Lusitania up until the closure of the Portuguese section in 2012.
* Badajoz–Elvas, currently in operation. It currently only sees two regional trains a day, that start their service at the Portuguese station of Entroncamento and end at Badajoz.
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.

## Subsidies

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.