The Battle of Pichincha took place on 24 May 1822, on the slopes of the Pichincha volcano, 3,500 meters above sea-level, right next to the city of Quito, in modern Ecuador. The encounter, fought in the context of the Spanish American wars of independence, pitted a Patriot army under General Antonio José de Sucre against a Royalist army commanded by Field Marshal Melchor Aymerich. The defeat of the Royalist forces loyal to Spain brought about the liberation of Quito, and secured the independence of the provinces belonging to the Real Audiencia de Quito, or Presidencia de Quito, the Spanish colonial administrative jurisdiction from which the Republic of Ecuador would eventually emerge. Background The military campaign for the independence of the Presidencia de Quito could be said to have begun on October 9, 1820, when the port-city of Guayaquil proclaimed its independence from Spanish rule after a quick and almost bloodless revolt against the local colonial garrison. The leaders of the movement, a combination of Venezuelan and Peruvian pro-independence officers from the colonial army, along with local intellectuals and patriots, set up a governing council and raised a military force with the purpose of defending the city and carrying the independence movement to the other provinces in the country. By that time, the tide of the wars of independence in South America had turned decisively against Spain: Simón Bolívar's victory at the Battle of Boyacá (August 7, 1819) had sealed the independence of the former Viceroyalty of Nueva Granada, while to the south, José de San Martín, having landed with his army on the Peruvian coast in September 1820, was preparing the campaign for the independence of the Viceroyalty of Perú. First Campaigns in the Real Audiencia de Quito (1820-1821) There were three military attempts to liberate the territory of the Real Audiencia. The first campaign was carried out by the new independent government of Guayaquil, which raised an army with local recruits — perhaps 1,800 men strong — and in November 1820 sent it towards the central highlands, with the purpose of encouraging other cities to join the independentist cause. After some initial successes, which included the declaration of independence of Cuenca, on November 3, 1820, the Patriots suffered a costly defeat at the hands of the Royalist army at the Battle of Huachi (November 22, 1820), near Ambato, forcing the Patriots to retreat back to the coastal lowlands. By