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
José de San Martín that it was not possible to defend Concepción, so he ordered O'Higgins to leave the city. 50,000 Chileans took cattle and grain and moved north, burning everything else, so that they did not leave supplies for the royalists. As he had done with the Tucumán Congress, San Martín urged a declaration of independence, to legitimize the government and the military actions. The Chilean Declaration of Independence was issued on 18 February 1818, one year after the battle of Chacabuco. San Martín, Las Heras and Balcarce met in Curicó, and the royalists in Talca, in a plain known as "Cancha rayada".