Meanwhile, in Peru a similar conflict for independence has begun in 1809. During the previous decade Peru had been a stronghold for royalists, who fought those in favor of independence in Upper Peru, Quito and Chile. Local attempts at establishing juntas, led by Criollos in Huánuco in 1812 and during the rebellion of Cuzco from 1814 to 1816, were suppressed. Peru finally began to succumb in 1817 under the military pressure of José de San Martín. With large parts of Peru now independent, San Martín transited the Andes to Mendoza in Argentina, and then across into Chile, alongside his political ally O'Higgins, defeating royalist forces in the third and final part of the Chilean war, the "Patria Nueva" campaign, culminating in the battle of Maipú. Combining Peruvian and Chilean independent forces, including the newly formed Chilean Navy, San Martín and Simón Bolívar completed their campaign in Peru, which formally declared independence in 1821.