The Vielha tunnel (Aranese: Tunèl de Vielha, Catalan and Spanish: Túnel de Viella) is a road tunnel in Spain, connecting Vielha, the capital of the Aran valley, with the Alta Ribagorça comarca. It is part of the N-230 road and consists of two parallel tunnels. The older one, named Alfonso XIII Tunnel in honour of Spanish king Alfonso XIII, was opened in 1948 and became the longest road tunnel in the world, with a length of 5240 metres, until 1964, when the Great St Bernard Tunnel was inaugurated.
The new tunnel, named Juan Carlos I Tunnel in honour of the Spanish king Juan Carlos I, is 5,230 metres (3.25 mi) long and was opened in 2007 with two lanes heading southbound and one lane northbound. The old tunnel is nowadays used as an emergency exit and since July 2011, also as a lane used by trucks which carry flammable or other types of hazardous loads.
Before the 20th century, the Aran valley was not easily accessible from the rest of Spain, especially during the winter snow season, when the Vielha mountain pass, at a height of 2.450 m above sea level, was frequently closed by snowfall. It would remain impassable to motor vehicles for many weeks, often longer.
In 1830, the politician Pascual Madoz had the idea of building the tunnel. That same year, two French engineers, Auriol and Partiot, prepared the first plans. Construction finally started in 1926 and lasted 22 years, including the Spanish Civil War period from 1936 to 1939. The tunnel was opened in 1948, drastically reducing the time required to access the valley and was at the time the longest road tunnel in the world. Heavy winter snowfall could still force the tunnel to close.
At the beginning of the 1980s the tunnel was reinforced, new asphalt was laid and new lighting installed. Curved concrete walls were built at both ends to avoid excessive air flow. During the 1980s and 1990s the tunnel began to struggle to meet the needs of the increasing vehicular traffic. The project of building a parallel new tunnel was requested in 1989 and approved in 1997. In 1999, after the Mont Blanc Tunnel accident, the project was accelerated.
In 2000 the old tunnel was ranked as the most dangerous tunnel in Europe due to the lack of security and emergency facilities. Construction of the new tunnel began in January 2002 and the work was temporarily stopped in winter 2005–2006 because the project had to be adjusted due to new safety laws. The new tunnel, named Juan Carlos I Tunnel in honour of Spanish king Juan Carlos I, was finally inaugurated on December 4, 2007.