An independent republic from the 7th century until 1073, Amalfi extracted itself from Byzantine vassalage in 839 and first elected a duke in 958; it rivalled Pisa and Genoa in its domestic prosperity and maritime importance before the rise of the Republic of Venice. In spite of some devastating setbacks it had a population of some 70,000 to 80,000 reaching a peak about the turn of the millennium, during the reign of Duke Manso (966–1004). Under his line of dukes, Amalfi remained independent, except for a brief period of Salernitan dependency under Guaimar IV.