There are several hypotheses about the origin of the name. The most famous is the one by Virgil. He stated that the name came from the wet nurse of Aeneas, “Cajeta”, buried here by Aeneas during his journey through Lazio coasts. Dante confirmed this event in the Divine Comedy. The first inhabitants arrived here during VIII century b.C.; in 345 b.C. the town was conquered by Romans and became an important holiday resort reached through Via Flacca.
After the fall of Roman Empire, Gaeta was sacked several times by barbaric populations and by Saracens. A castle was built as a defence and the inhabitants moved in it. Svevian king, Frederick II, stayed in Gaeta. During the fights between Guelphs and Ghibellines, in 1223 he ordered the walls for the town. In VIII century a.C. the town had become independent from the imperial authority.
The Dukedom of Gaeta was founded a century later when Giovanni I became the duke. It lasted two centuries in which the town was actually autonomous. The dukedom ended in 1140 when Gaeta was conquered by Ruggero II d’Altavilla, which left certain autonomy and the local coin to the town. During his reign and during the Svevian rule (1194-1266), Gaeta did not have a political importance. During Angevin rule (1266-1435), the town acquired new importance. In 1378 it became the temporary seat of the anti-pope Clement VII, allied to queen Giovanna I.
Aragon family conquered the town and stopped Angevin domination. During this period a new castle was built. The old one was enlarged and linked to the new one. On 24th June 1571 the pontifical fleet left from the port of Gaeta. Admiral Marcantonio Colonna led it. They met with the rest of Christian fleets led by Giovanni d’Austria to fight against Saracens. Before leaving, in the cathedral, Admiral Colonna promised to donate the Banner of Lepanto to the Cathedral in case of victory. He had received it from Pope Saint Pius V on 20th June 1571.
The battle fought by Christian fleet against Saracens took place on 7th October 1571 in Lepanto and Christians won. When he was back to Gaeta, Admiral Colonna donated the Banner, as he had promised. In 1734 Charles III of Bourbon family conquered Gaeta.
On 25th November 1848 Pope Pius IX took refuge in Gaeta after the proclamation of the Roman Republic by Giuseppe Mazzini. He stayed there until 4th September 1849. During this period the Pope received the famous revelation about the Immaculate Conception of Our Lady and he instituted the dogma when he came back to Rome. Gaeta was part of Campania until Fascist period when it was included in Lazio region.