Following the renewed independence of Peru, Peruvian president General Agustín Gamarra invaded Bolivia. On 18 November 1841, the battle de Ingavi took place, in which the Bolivian Army defeated the Peruvian troops of Gamarra (killed in the battle). After the victory, Bolivia invaded Perú on several fronts. The eviction of the Bolivian troops from the south of Peru would be achieved by the greater availability of material and human resources of Peru; the Bolivian Army did not have enough troops to maintain an occupation. In the district of Locumba – Tacna, a column of Peruvian soldiers and peasants defeated a Bolivian regiment in the so-called Battle of Los Altos de Chipe (Locumba). In the district of Sama and in Arica, the Peruvian colonel José María Lavayén organized a troop that managed to defeat the Bolivian forces of Colonel Rodríguez Magariños and threaten the port of Arica. In the battle of Tarapacá on 7 January 1842, Peruvian militias formed by the commander Juan Buendía defeated a detachment led by Bolivian colonel José María García, who died in the confrontation. Bolivian troops left Tacna, Arica and Tarapacá in February 1842, retreating towards Moquegua and Puno. The battles of Motoni and  Orurillo forced the withdrawal of Bolivian forces occupying Peruvian territory and exposed Bolivia to the threat of counter-invasion. The Treaty of Puno was signed on 7 June 1842, ending the war. However, the climate of tension between Lima and La Paz would continue until 1847, when the signing of a Peace and Trade Treaty became effective.