The Peruvian resistance continued for three more years. The leader of the resistance was General Andrés Cáceres (nicknamed the "Warlock of the Andes"), who would later be elected president of Peru. Under his leadership, the Peruvian militia forces heightened with Indian "montoneras" inflicted several painful blows upon the Chilean army in small battles such as Marcavalle, Concepción and San Pablo, forcing Colonel Estanislao del Canto's division to return to Lima in 1882. However, Caceres was conclusively defeated by Colonel Alejandro Gorostiaga at Huamachuco on July 10, 1883. After this battle, there was little further resistance. Finally, on 20 October 1883, Peru and Chile signed the Treaty of Ancón, by which Peru's Tarapacá province was ceded to the victor; on its part, Bolivia was forced to cede Antofagasta.