In 523, the town was invaded by the Franks, followed in 574 by the Lombards and in the mid-10th century, by the Saracens. In 888 Rudolf of Welf was crowned King of Burgundy in the Abbey. In 1034, the entire Chablais region, which included Saint-Maurice, was acquired by the Duchy of Savoy. The towns of Saint-Maurice and Monthey formed a "Kastlanei" or district. Around 1300, the "Kastlan" or vogt moved from Monthey to Saint-Maurice. The abbot exercised dominion over the abbey and the town. Citizens of the town were first mentioned in 1170 and by 1275, the citizens elected two mayors. In the 13th century the town was surrounded by walls. Count Amadeus V of Savoy confirmed the city charter in 1317, at which time the town had a population of between 1,400 and 1,800. In 1475 the Lower Valais was ruled by the Seven Zenden as an associate member (Zugewandter Ort) of the Swiss Confederation. From 1475 until 1798, Saint-Maurice was the capital of the Saint-Maurice province.