After Archduke Karl's Austrian army was defeated by Napoleon at the Battle of Wagram, the Armistice of Znaim was signed. Point IV of the agreement stated that Austria was to withdraw its troops from the territories of Vorarlberg and Tyrol, returning them to Bavarian rule. But the Bavarians and the French found it difficult to gain control of the territory, with Tyrolean sharpshooters occupying high places along the roads, blocking roads and setting off avalanches to harm the occupying army. The Tyroleans managed to hold off and inflict heavy casualties on the French and Bavarian troops, and on August 13 the Tyrolean peasant army rallied at the Bergisel again for the decisive Battle. 15000 Bavarian, French and Saxon troops faced almost the same number of Tyrolean irregulars. Surrounded on all sides by the irregulars, and having sustained heavy casualties, Lefebvre was forced to withdraw. Andreas Hofer, who in the meantime had advanced to supreme commander of the insurgents, became regent of Tyrol in the name of the Emperor.