Before the Spanish, Puerto Rico was Borikén, the island of the Taíno people. Christopher Columbus reached it on his second voyage in 1493, and in 1508 Juan Ponce de León founded the first settlement, Caparra, across the bay. In 1521 the settlement moved to the islet at the harbour mouth, and over time the city took the name San Juan and the island the name Puerto Rico ("rich port").
As the gateway to Spain's Caribbean empire, San Juan was fortified for over two centuries: Castillo San Felipe del Morro, Castillo San Cristóbal and the city walls beat off attacks by the English under Francis Drake (1595), the Dutch (1625) and the British (1797), though the Earl of Cumberland briefly took the city in 1598. Enslaved Africans were brought to work sugar plantations; slavery was abolished in 1873.
After the Spanish-American War of 1898, Puerto Rico became a territory of the United States. Puerto Ricans have been US citizens since 1917, and since 1952 the island has been a self-governing commonwealth (Estado Libre Asociado). Hurricane María in 2017 devastated the island; recovery took years and shaped today's island. The forts and walls are protected as San Juan National Historic Site and a UNESCO World Heritage Site.