The first railway in Costa Rica was reputedly a tramway with donkey haulage, opened some time in the 1850s between Puntarenas and Esparza (about 13 miles, 21km), although little information seems to be available relating to this line. At Esparza it connected with an ox cart trail leading to the capital city, San José, located in the mountainous centre of the country.
The first steam hauled railway was the line from the moutain city of Alajuela to Puerto Limón on the Atlantic (Caribbean) coast. The first section, from Alajuela to San José (about 13 miles, 20km), opened in 1873. It was built to 3ft 6in (1067mm) gauge. Materials for the construction of the line had to be brought in from the Pacific Coast by way of the ox cart trail mentioned above.
The tramway from Puntarenas to Esparza was replaced by a railway in 1879, but the ox trail remained in use until the final section of the Pacific Railway was opened in 1910, completing a transcontinental connection from the Pacific to the Atlantic Coasts via San José. The importance of the new line can be judged from the fact that the 75 mile (120km) section from Puntarenas to San José was electrified as early as 1930.
In addition to the main line railways, there were at one time a large number of minor narrow gauge railways, mainly serving the banana industry, on many of which traction was provided by horse or manpower rather than by steam. A steam powered street tramway operated in Cartago for just 10 years from 1888. Horse drawn trams operated in San José from 1889; this line was electrified in 1899 and subsequently extended, eventually closing in 1950.
Meanwhile the main lines continued in service though in a state of decline by the 1990s. Damage caused by a 7.5 magnitude earthquake in 1991 and again by Hurricane Cesar in 1996 led to the complete cessation of operations. The system lay disused until the government launched an initiative for reconstruction in 2000. Although progress has been slow, by 2014 regular passenger services were operating from San José to Belén (12km) on the line to Caldera, to Cartago (13km), and local destinations Heredia, Pavas and Curridabat. Freight trains operate between San José to Caldera (140km), and from Limón on the Caribbean coast to Monteverde and Anita Grande. Incofer also operates tourist charter services on behalf of specialist holiday companies.