In 1817, the
José de San Martín led an army
across the Andes and defeated the Spanish at the battles of
Chalchuapa and captured
Santiago. The Spanish viceroyalty sent a Spanish army to Santiago under General
Mariano Osorio, which defeated San Martín at the
Second Battle of Cancha Rayada. The drive for independence never diminished, however, and the following year San Martín launched a final offensive, which was to decide the outcome of the war.
Despite being defeated at Cancha Rayada, the Patriot army regrouped again in less than two days, adding up to about 4,000 men, allowing San Martín to rebuild his units almost entirely. Hence, on April 2, after leaving the
Ochagavía camp to travel to the lower hills of
Maipo, the Patriot army emerged organized in three infantry divisions with a total of 396 chiefs and approximately 5,000 lower-ranked officers and soldiers.
The Royalist army meanwhile continued in its attempt to consolidate and defeat the Patriots, and after Cancha Rayada begun a persistent and extenuating persecution, which was resisted in every town and countryside, delaying its advance towards Santiago and giving the Patriots some time to reorganize and to plan the way to stop Osorio and to avoid his entrance into the capital city.
Foreseeing this situation, General
Bernardo O’Higgins employed some important measures which would serve the ultimate goal of defeating the Spanish, such as collecting the rifles and sabres given by
Manuel Rodríguez to people after Cancha Rayada; speeding up the incoming supplies from Los Andes; acquiring or confiscating weapons held by individuals and merchants of Santiago to rearm the troops; gathering up combatants from the population coming up from the south and organizing a training camp at Ochagavía.
Meanwhile, Gen. Osorio, after passing through
San Fernando by the end of March, realized that he had not defeated the Patriot army conclusively at Cancha Rayada, and moreover, that the latter was fit to fight and to win. Facing this fact, another encounter between the Patriots and Royalist army near Santiago became inevitable.
Both armies established their headquarters near each other in the south of Santiago, where San Martín and Osorio prepared for battle.
At nightfall on April 4, the Royalist army settled at Lo Espejo, about seven kilometres from the Patriot forces. At dawn the next day, San Martín occupied the lower hills over the southern edge which runs from west to east, with
Las Heras’ division to the right, Alvarado's division on the left and Quintana's division right behind them. The
grenadiers were set on the extreme right and the Cazadores of the Dictatorial Army were arranged on the left flank. The artillery was divided into two brigades under Blanco Encalada and Borgoño, and protected by the infantry on the wings.
Osorio arranged his army on a triangular ridge at north of Lo Espejo. Primo de Rivera's division was formed on the left wing, while the Dragones de la Frontera Regiment was deployed over the road to
Valparaíso. Morla's Division was set on the western half of the triangular plateau, and the right flank was formed by the Ordoñez Division.