After the successful Garfagnana Wars (1604-1620) against the Este family, the city of Lucca enjoyed a period of peace and prosperity until the arrival of Napoleon's troops in 1799. Lucca's policy was to adopt certain ideals to maintain its freedom: staying on the sidelines of international events, avoiding threats and conflicts with its neighbors, and creating a powerful defensive system to deter potential invasions. Much of the state's financial resources were invested in the construction of the final city walls, completed in 1645.
The fertile countryside, the economic fabric of small and medium-sized businesses, and the social peace protected by the government allowed the population to maintain its well-being. In 1628, Lucca definitively became an oligarchic republic: the General Council established the Golden Book of the 224 families who could access the highest offices, following the example of Venice. This decision impoverished and rigidified the political system, tending to progressively isolate the city and disengage from the commercial momentum it had previously embraced.
The European situation, coupled with protectionist policies, forced the people of Lucca to relocate to increasingly distant and difficult locations. Beginning in the 16th century, much of their capital was reinvested in agriculture, with land reclamation and cultivation extending throughout the Republic, which further enriched itself with noble villas. Maintaining this profitable prospect, in the 18th century, the excellent state of finances allowed for consideration of paying off the public debt. The government began timidly to undertake some Enlightenment-inspired reforms: in 1758, a piracy operation allowed Ottaviano Diodati and his collaborators to print the first Italian edition of Diderot and D'Alembert's Encyclopédie. Furthermore, the University was inaugurated in 1790.
Due to its cosmopolitan vocation, due to the continuous link with the world of business, commerce and culture, Lucca has never had a simple "provincial" dimension. With the Congress of Vienna (1815), Lucca was constituted as a duchy (Ducatus Lucensis) under the sovereignty of Maria Luisa of Bourbon and then of her son Charles Louis. Lucca became the capital and remained so until its transfer to the Grand Duchy of Tuscany in 1847.
The city experienced a period of great economic prosperity in the second half of the 19th century, especially in the agri-food, textile, and paper sectors through the exploitation of the area's water resources.