He joined San Martin's Army of the Andes, and fought at Torata and Moquegua. In this last battle he was wounded and taken prisoner again being moved to Chicuito island on Lake Titicaca, until he was freed after the royalist surrender at the Battle of Ayacucho. Casanovas returned to Buenos Aires in 1824 and was named an officer of the dragoons regiment.