Medieval Amalfi was ruled, in the tenth and eleventh centuries, by a series of dukes (), sometimes called dogi (singular: doge), corresponding with the republic of Venice, a maritime rival throughout the Middle Ages. Before the title of Duke of Amalfi was formally established in 957, various patricians governed the territory. Amalfi established itself as one of the earliest maritime trading powers renowned throughout the Mediterranean, considered for two centuries, one of the most powerful of the maritime republics. The title of Duke of Amalfi was reestablished as a Spanish dukedom in 1642 by King Philip IV of Spain for Ottavio Piccolomini, an Imperial field marshal. Of noble Tuscan descent, two popes were scions of the Piccolomini family, and the first duke's younger brother, Ascanio II Piccolomini, served as archbishop of Siena from 1628 until 1671. King Alfonso XIII of Spain revived the dukedom in 1902, and the title is extant. Independent rulers (839–1100) Prefects The prefecture's establishment is not certain, but the first elected prefect of Amalfi was in 839. Peter Marinus (first time) Sergius (I) 860–866 Maurus 870–876? Marinus (second time) 872–879 Pulcharius (co-ruled with Marinus) 883 Sergius (II) 898 Stephen 898–914 Manso (I) Patricians The time of the patricians (or judges) is not well known. The numbering of the rulers of Amalfi usually begins again with the judgeship. Mastalus was elected judge upon his succession in 914. 914–953 Mastalus I 920–931 Leo 939–947 John (I) 953–957 Mastalus II Dukes Mastalus was elected duke on his coming of age, but died the next year. A new dynasty was then inaugurated. It reigned uninterrupted for the next 115 years, except during the period 1039–1052, when the duke of Salerno conquered the duchy. 957–958 Mastalus II House of Musco Comite 958–966 Sergius I (II) 966–1004 Manso I (II), also Prince of Salerno (981–983) 984–986 Adelfer, in opposition to Manso 1004–1007 John I (II), also Prince of Salerno (981–983) 1007–1028 Sergius II (III) 1028–1029 Manso II (III) under regency of 1028–1029 Maria, his mother 1029–1034 John II (III) 1034–1039 Maria, again, with 1034–1038 Manso II (III), again, her son 1038–1039 John II (III), again, her son House of Salerno 1039–1052 Guaimar I, also Prince of Salerno (1027–1052) 1043–1052 Manso II (III), under overlordship of Guaimar, deposed 1047–1052 Guaimar II, son, co-ruled with his father Manso, deposed House of Musco Comite 1052–1069 John II (III), again 1069–1073 Sergius III (IV) 1073 John