The population of Buenos Aires was highly militarized during the British invasions of the Río de la Plata, part of the Anglo-Spanish War. Buenos Aires was captured in 1806, and then liberated by Santiago de Liniers with forces from Montevideo. Fearing a counter-attack, all the population of Buenos Aires capable of bearing arms was arranged in military bodies, including slaves. A new British attack in 1807 captured Montevideo, but was defeated in Buenos Aires, and forced to leave the viceroyalty. The viceroy Rafael de Sobremonte was successfully deposed by the criollos during the conflict, and the Regiment of Patricians became a highly influential force in local politics, even after the end of the British threat.