In 840, Duke Sergius I made the succession to the duchy hereditary, and thenceforth Naples was "de facto" independent. In this age, the city was mainly a military centre, ruled by an aristocracy of warriors and landowners, even though it had been compelled to surrender to the neighbouring Lombards much of its inland territory. Naples was not a merchant city as other Campanian sea cities like Amalfi and Gaeta, but had a respectable fleet who took part in the Battle of Ostia against the Saracens in 849. Anyway, Naples did not hesitate to ally with infidels if this turned to its advantage: in 836, for example, it asked support to the Saracens in order to push off the siege of Lombard troops coming from the neighbouring Duchy of Benevento. After its dukes rose to highest prominence under the Duke-Bishop Athanasius and his successors—of whom Gregory IV and John II participated at the Battle of the Garigliano in 915—Naples declined in importance in the tenth century, until it was captured by its traditional rival, Pandulf IV of Capua.