During the Napoleonic Wars Tyrol was ceded to Bavaria, ally of France. Andreas Hofer led a Tyrolean peasant army to victory in the Battles of Bergisel against the combined Bavarian and French forces, and then made Innsbruck the centre of his administration. The combined army later overran the Tyrolean militia army and until 1814 Innsbruck was part of Bavaria. After the Vienna Congress Austrian rule was restored. Until 1918, the town (one of the 4 autonomous towns in Tyrol) was part of the Austrian monarchy (Austria side after the compromise of 1867), head of the district of the same name, one of the 21 "Bezirkshauptmannschaften" in the Tyrol province.