In 1879, Chile and Bolivia went to war after spending decades bickering over a border dispute. Peru, which had a military alliance with Bolivia, was drawn into the war as well. After a series of major battles at sea and on land, the Chileans were victorious. By 1881 the Chilean army had captured Lima and by 1884 Bolivia signed a truce.
As a result of the war, Chile gained the disputed coastal province once and for all, leaving Bolivia landlocked, and also gained the province of Arica from Peru. The Peruvian and Bolivian nations were devastated, needing years to recover.