In 1812 Lavalle joined the Regiment of mounted grenadiers as a cadet. By 1813 he reached the grade of lieutenant and moved to the army, which under orders of Carlos María de Alvear besieged Montevideo. Lavalle fought against José Gervasio Artigas in 1815 and in the Battle of Guayabos under the command of Manuel Dorrego. In 1816 Lavalle moved to Mendoza to join the "Army of the Andes" of the "liberator" José de San Martín and fought in Chacabuco and the Maipú in Chile. He continued along with San Martín on his way to Peru and Ecuador and took part in the battles of Pichincha and the Riobamba, after which he became known as the "Hero of Riobamba".