Livorna is mentioned for the first time in 1017 as a small coastal village, the port and the remains of a Roman tower under the rule of Lucca. In 1077, a tower was built by Matilda of Tuscany. The Republic of Pisa owned Livorna from 1103 and built a quadrangular fort called "Quadratura dei Pisani" ("Quarter of the Pisans") to defend the port. "Porto Pisano" was destroyed after the crushing defeat of the Pisan fleet in the Battle of Meloria in 1284. In 1399, Pisa sold Livorna to the Visconti of Milan; in 1405 it was sold to the Republic of Genoa; and on 28 August 1421 it was bought by the Republic of Florence.