After the fall of the Western Empire, the city was repeatedly sacked by Ostrogoths, Burgundians, Byzantines, Lombards, Franks, Hungarians and Saracens. In the 11th century it became a free commune (or city-state) and was a member of the Lombard League. Montferrat and the Visconti fought over the town; later it became a possession of the Gonzaga. Charles Emmanuel I of Savoy conquered it twice, while later France and Spain battled for its possession. The Treaty of Cherasco (1631) assigned Alba definitively to Savoy. During Napoleonic Wars, it was part of the Republic of Alba (1796) and of the Subalpine Republic, both French clients, before being annexed to the French Empire in 1802. It was an arrondissement center in firstly Tanaro department between 1802-1805, later in Stura one between 1805-1814 before liberation by Austrian troops. It was returned to Kingdom of Sardinia (Duchy of Savoy's name after gaining Sardinia in 1720) in 1814.