Originally Etruscan and then Roman colony, in the Early Middle Ages Lucca was seat of a Lombard duchy and later capital of the March of Tuscany. Its true expansion took place in the course of the XIIth century when the town became a free commune. A thriving trade centre, Lucca gained increasing control over the Plain and Versilia, fighting against mighty feudal lords, conquering their castles and successfully defending the new territories against Pisa. The Roman walls were replaced by a new circle of walls, finished by 1260: a fortress with a number of towers semicircular, four gates with drawbridge and a moat surrounding the town entirely. Under Castruccio Castracani Lucca engaged in a series of wars culminating with the capture of Pistoia and the expansion as far north as Pontremoli in upper Lunigiana. Castracani's sudden death marked the beginning of an unfortunate period for the town, taken by the Pisans in 1342 and finally liberated by Emperor Charles IVth of Bohemia only in 1369. At the beginning of the XVth century Lucca enjoyed a period of peace and prosperity under Paolo Guinigi. At his fall in 1430 the Republican regime was restored, to last until 1799. In 1805 the Principate of Lucca was established, became then a Duchy under Maria Luisa di Borbone, from 1817 to 1824 and was finally incorporated in the Grand Duchy of Tuscany.