The Caribbean coast of Panama was explored by a Spanish expedition under Rodrigo de Bastidas about 1500. The region was inhabited by several tribes of Indians, the Cuna being the largest. In 1502 Christopher Columbus sailed along the coast to the central part of the isthmus and claimed the area for Spain. The northern coast of Panama was the location of the first Spanish settlement on the mainland.

In 1509 the Spanish government issued licenses to Alonso de Ojeda and Diego de Nicuesa to settle the regions explored by Bastidas and Columbus. The first colonies were established in 1510 at San Sebastián (on what is now the northern coast of Colombia) and Nombre de Dios. They did not flourish, however, because of disease, famine, and conflicts with the Indians. The first successful settlement, Santa María, was founded in 1510, when Vasco Núñez de Balboa convinced the settlers at San Sebastián to move to a new location on the west shore of the Gulf of Darien. The Indians at the new site were quickly subdued and Balboa became governor of the new colony. In 1513 Balboa made his way across the isthmus and discovered the Pacific.

Balboa's New World journeys.Balboa's New World journeys. The smaller map shows Vasco Núñez de Balboa's route from Spain to the Caribbean in 1501. The larger map shows his routes through the Caribbean Sea. During 1501 and 1502, Balboa sailed along the northern coast of South America and up to Hispaniola. He helped establish the colony of Darien in 1510. In 1513, Balboa crossed the Isthmus of Panama and sighted the Pacific Ocean.

Balboa was replaced in command, and later put to death, by Pedrarias de Avila, who in 1519 founded the city of Panama on the south coast of the isthmus to serve as the seat of government. Francisco Pizarro in 1531 launched his conquest of Peru from the new city. A stone road was built from Panama City to Portobelo, and all gold, silver, and gems taken from Peruvian mines passed across it to be loaded in Spanish galleons on the Caribbean coast.

Privateers of other European countries, especially of England, harassed the Spanish Main (mainland). In 1572 Francis Drake seized a mule train of treasure crossing the isthmus. At the time of his death in 1596 he was preparing to attack Portobelo. The port was captured in 1601 by William Parker, and was sacked in 1668 by Henry Morgan, who returned in 1671 to plunder and burn Panama City. In 1698 a Scottish company attempted to plant a colony at Caledonia Bay, but the Spanish drove them out. British Admiral Edward Vernon captured Portobelo in 1739. In 1746 Spain abandoned the route across the isthmus in favor of the sea route around Cape Horn, and Panama's prosperity quickly disappeared.

During the early colonial period Panama was an administrative district within the viceroyalty of Peru. In 1739, however, it was united with Colombia in the viceroyalty of New Granada. When commerce declined after 1746, Panama lost its economic importance and its separate administration was abolished. Thereafter, it was governed from Bogotá.