In 1817, the Argentine General José de San Martín led an army across the Andes and defeated the Spanish in the battle of Chacabuco and captured Santiago.
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.
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.
The infantry advanced in columns without retaliating fire, until Las Heras threw his troops against Primo de Rivera with the support of Blanco Encalada's artillery, while Alvarado did the same against Ordóñez being covered by Borgoño's batteries.
The grenadiers under Zapiola were assailed by part of the Royalist cavalry, but managed to counterattack and chase the attackers to a little slope where they were decimated by a dense infantry and artillery fire.
The rest of the Royalist units formed in squares endured up to ten cavalry melees, but retreated after the centre and right wing withdrew to Lo Espejo.
Pushed by the Patriot infantry, Ordóñez' men garrisoned on the houses of Lo Espejo were forced to surrender, while the militias brought by O'Higgins captured the dispersed soldiers.