The real rise of Lucca dates from the end of the twelfth century when many of the nobility moved within the city walls, declared themselves ready to defend them, and chose a Podestà as their head. But the ensuing centuries found Lucca often in conflict with other comuni such as Florence and Modena, with the Church especially over control of the Garfagnana mountains, and with the nearby sea republic of Pisa which sacked Lucca in 1314 in order to form with it a strong ghibelline force against Florence. Due to a series of unfortunate political manoeuvres, Lucca next found itself tossed from one owner to another. First it was sold to Francesco Castracani, then to Gherardo Spinola, to John of Bohemia, to the Rossi of Parma, the Scaligeri of Verona, and to Florence from where it passed back to Pisa in 1342. In 1369 Emperor Charles IV freed Lucca of Pisa, and although he kept it somewhat under himself, he allowed it to write a statute as a republic in 1372. Unfortunately independence soon gave way to domination by Paolo Guinigi who managed to keep control from 1400 to 1430. Only then was Lucca once again able to assert itself as a republic, a situation it guarded proudly and jealously for three centuries, until 1799 when France and Austria began. alternately to occupy it. In 1805 Napoleon installed his sister Elisa Bonaparte and her husband Felice Baciocchi as rulers of what then became the Principality of Lucca.