The Spanish attacked at 19:30, when the last thing the patriots expected was a battle. In a bold move, Ordoñez made the kind of attack San Martín had most feared: circumventing the city and making a surprise attack at night behind the vanguard where the patriot forces were still taking positions. The surprise attack happened before the patriot army had re-positioned itself, and was a directed at the
battalion under General
Bernardo O'Higgins command, near San Martín's position. Soon, the vanguard soldiers dispersed, leaving O'Higgins in a bad position; his horse was shot dead and he was wounded in one arm. In an uncharacteristic move, instead of ordering retreat San Martín held the position, which made more patriot soldiers flee under enemy fire, leaving their weapons and supplies behind. After the initial disorder, however, he ordered retreat. The rear and reserves had already re-positioned, somewhat withstanding the attack, but had no-one in command, since their chief, Colonel
Hilarión de la Quintana, had left for headquarters to receive orders after the re-position and had not yet returned. Colonel
Juan Gregorio de Las Heras took command, and led the men during the retreat, while trying to recover as much artillery and weapons as possible. San Martín and O'Higgins (who were also retreating at full speed) were being closely chased by royalist forces. ==Aftermath==