In the context of the 1701–1714 War of Spanish Succession, the city rose in arms in favour of the Archduke Charles, who was proclaimed "King of Aragon" in the city on 29 June 1706, following the uprising of other parts of the Kingdom of Aragon in December 1705. Charles entered the city in July 1706, directing the attack on those places of Aragon that had sided with the Bourbon faction such as Borja or the Cinco Villas. Following the April 1707 battle at Almansa, the tide turned with the "Austracist" forces fleeing in disarray, and the Bourbon forces commanded by the Duke of Orléans entering the city on 26 May 1707. As he seized control of the kingdom, he began to enact the series of institutional reforms known as the Nueva Planta, abolishing the Aragonese institutions in favour of the Castilian ones. The war turned around again in 1710 after the Battle of Almenar, and, following another Bourbon defeat near Zaragoza on 20 August 1710, Archduke Charles returned to the city on the next day. This was for only a brief period, though, as following the entry of Philip V in Madrid and the ensuing Battle of Villaviciosa in December 1710, the Habsburg armies fled from Zaragoza in haste in December 1710 and Philip V proceeded to consolidate his rule over the kingdom of Aragon, resuming administrative reforms after a period of institutional void.