The first settlements in the territory of Gaeta date back to eighth century BC. About the etymology there have been several hypotheses; the older derives its name from "Caieta", mentioned by Virgil [70-19 BC] (' Aeneid ', 7, 1), and the nurse of Aeneas, from the Greek "Kaien" ("burn"), because the Trojans set fire to the ships of Aeneas. [See V. Teti, “Storia dell'acqua: mondi materiali e universi simbolici” [“History of water: physical worlds and symbolic universes”], Donzelli, 2003: 75, footnote 20]. Of course, contemporary proposals indicate the origin of the Latin name "Caieta" from a typical feature of the site where is located the city.

Indeed Professor Marta Sordi, internationally known scholar, writes that "[...] 'Caieta' is not so named in memory of the nurse of Aeneas (...) but as ‘concave’; in Greek are defined 'kaietai' all objects concave [...]" (see M. Sordi, “Autocoscienza e rappresentazione dei popoli nell'antichità” [“Self-awareness and representation of the peoples of antiquity”], Ed. Vita e Pensiero, 1992: 180). In 345 BC the city was conquered by the Romans, who transformed it into a resort.

With the fall of the Roman Empire, Gaeta suffered many looting by barbarians and Saracens. To defend the city was built the castle. In the eighth century AD, The town freed itself from the imperial authorities and a century later it gave rise to the Duchy of Gaeta. The experience of the duchy ended in 1140, when Gaeta was captured by King Roger II of Hauteville (1095-1154).  At the time of the Angevins Domination, the city repeatedly has an important role.

In 1442 Alfonso of Aragon (1396-1458) defeated Renato, the last ruler of Anjou (1409-1480) in southern Italy. During the Aragonese domination was built a new castle (called "Angevin"), while the old one was restored and joined the new. Under the Spanish, Gaeta grew even more its importance, because of its strategic and military location. Indeed, the proclamation of the Roman Republic led Pope Pius IX (1792-1878), in 1848, to take refuge at Gaeta, under the protection of the Bourbons.

Gaeta was annexed to the Kingdom of Italy with the national unification.