The Duchy of Gaeta was an early medieval state centered on the coastal South Italian city of Gaeta. It began in the early ninth century as the local community began to grow autonomous as Byzantine power lagged in the Mediterranean and the peninsula due to Lombard and Saracen incursions.
The primary source for the history of Gaeta during its ducal period is the Codex Caietanus, a collection of charters preserving Gaetan history better and in greater detail than that of its neighbouring coastal states: Naples, Amalfi, and Sorrento. However, unlike these sister seaports, Gaeta was never a centre of commercial importance. In 778, it was the headquarters from which the patrician of Sicily directed the campaign against the Saracen invaders of Campania.
The first consul of Gaeta, Constantine, who associated his son Marinus with him, was a Byzantine agent and a vassal of Andrew II of Naples. Constantine defended the city from the ravages of Muslim pirates and fortified it, building outlying castles as well. He was removed, probably violently, by the Docibilis I, who established a dynasty and made Gaeta de facto independent.
The Docibilian dynasts regularly worked to advance Gaetan interests through alliance with whatever power was most capable of such at the time. They joined forces with the Saracens against their Christian neighbours and with the Pope against the Muslim pirates at the Battle of Ostia. They constructed a massive palace and greatly increased the city's prestige and wealth. The Gaetans remained nominally Byzantine in allegiance until the mid tenth century, fighting under their banner at the Battle of the Garigliano. The chief success of the Docibilians lay, however, in extracting Gaeta from the Ducatus Neapolitanus.