The original Panama City was founded in 1519 by Spaniards serving with Pedrarias Dávila, the colonial governor of the area. It was used as a base for Spanish forces to explore and conquer South America, especially the empire of the Inca in Peru. Soon the city became an important point for moving people and goods between Europe and the west coast of South America. These goods included silver from Peru, which the Spanish shipped across the Isthmus of Panama and back to Spain. This early city, now called Panama Viejo (Old Panama), was looted and burned in 1671 by Welsh pirate Henry Morgan. Spanish officials rebuilt the city two years later on a site that would be easier to defend: a peninsula about 8 km (about 5 mi) southwest of the first site.
Panama City declined in the 1700s, as the Spanish began to use different trade routes. However, the California gold rush and the construction of the Panama Railroad in the 1850s revived travel across Panama and brought the city a period of renewed prosperity and growth. At this time, Panama was part of Colombia, and Panama City served as the political center of the region. It became the national capital when Panama seceded from Colombia and declared its independence in 1903.