Battle of Ayacucho own. The royalists in each viceroyalty, however, took different paths. In New Spain, royalists, after defeating the insurgents, proclaimed a negotiated separation from Liberal Spain through the Plan of Iguala, which they negotiated with the remaining patriots, and the Treaty of Córdoba, which they negotiated with the new head of government, Juan O'Donojú. In Peru Viceroy Joaquín de la Pezuela was discredited after a royalist expedition to Chile under Mariano Osorio was defeated and advances in Peru were made by José de San Martín. The viceroy was overthrown on 29 January 1821, in Asnapukyu "(Aznapuquio)", in a coup by General
Army of the North of the Royalist forces in Upper Peru. On 12 May Orozco commanding a force of 4,000 men advanced to Jujuy, and on 28 May occupied the city, then on 31 May occupied Salta. On 2 June the royalist forces defeated the patriots at Chamical (southwest of the city of Salta). At the battle of Las Cañas lieutenant colonel Rojas was killed but the force of 400 royalists was defeated. On 8 June there was a new independentist victory at Cuesta de la Pedrera (southeast of Salta), dispersing 2,000 royalists who retreated to Jujuy. At the battle of Yala another royalist