The dukes of the Duchy of Naples were initially military commanders, called dux or magister militum, appointed by the Byzantine emperor; the emperor retained interest until the 9th century, when Sergius I was elected by citizens and subsequently made his position hereditary.