The first railway in Panama was the Panama Railroad, which crossed the isthmus in 1855. At a time when traffic between the Atlantic and Pacific coasts of the United States of America was growing rapidly, it was built to provide an alternative to the lengthy sea voyage around Cape Horn. The 47 mile (75km) railway was built to the unusual gauge of 5ft (1524mm).
A French scheme for the construction of a canal across the isthmus failed in the 1890s. In 1903, Panama obtained independence from Colombia as a protectorate of the United States. The US government revived the canal scheme, the area in its immediate vicinity became the Canal Zone, directly administered by the US.
The Panama Canal opened in 1914. The Panama Railroad had been used extensively during the construction of the canal. A few sections had to be diverted from their original route, but a refurbished line was opened from coast to coast in 1912, and remained in as an alternative to the Canal and to serve internal traffic needs of the Canal Zone.
At the end of the 20th century, sovereignty of the Canal Zone was returned to the Republic of Panama. The original Panama Railroad was closed for a while, before being refurbished and restored as a modern, standard (1435mm) gauge line: the Panama Canal Railway. A healthy amount of freight traffic operated the length of the line, together with daily passenger services.
The Panama Canal, meanwhile, has its own railway system which is used for works purposes, and most notably by the powerful railway locomotives (known as “mules”) which tow ocean going vessels through the lock systems at Milaflores and Gatun. This railway retains its original 5ft (1524mm) gauge.
There was also a network of 3ft (914mm) gauge lines, used primarily by the banana industry, in the north of the country near the border with Costa Rica, and even extending a short distance across the border. Most were closed in the last decades of the 20th century, although one line continued in operation until 2008.
A new 14 km metro system for Panama City is under construction.