Canterac was defeated on August 6, 1824 by Simón Bolívar at Junín. De la Serna was now resolved to risk everything to crush the revolt. He left Cuzco in October with a well-disciplined army of 10,000 infantry and 1,600 cavalry. He met the insurgent army in the mountain plain of Ayacucho on December 8, and the following day was totally defeated by General Antonio José de Sucre. De la Serna was wounded and taken prisoner. The Royalist army had 2,000 dead and wounded and lost 3,000 prisoners, with the remainder of the army entirely dispersed. General Canterac, the second in command, signed an honorable capitulation the next day, December 9, 1824. De la Serna, who on the date of the battle had been created conde de los Andes by King Ferdinand VII, was released soon afterward and sailed for Europe. In all but name, the Spanish Viceroyalty of Peru was at an end.