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
Palmares (quilombo) This government was confederate in nature, and was led by an elected chief who allocated landholdings, appointed officials (usually family members), and resided in a type of fortification called Macoco. Six Portuguese expeditions tried to conquer Palmares between 1680 and 1686, but failed. Finally the governor of the captaincy of Pernambuco, Pedro Almeida, organized an army under the leadership of the Bandeirantes Domingos Jorge Velho and Bernardo Vieira de Melo and defeated a palmarista force, putting an end to the republic in 1694. Palmares was the general name given by the Portuguese in Pernambuco and Alagoas to the interior districts