Peru was heavily indebted, and political in-fighting was again on the rise. Peru embarked on a railroad-building program that helped but also bankrupted the country. In 1879, Peru entered the War of the Pacific which lasted until 1884. Bolivia invoked its alliance with Peru against Chile. The Peruvian Government tried to mediate the dispute by sending a diplomatic team to negotiate with the Chilean government, but the committee concluded that war was inevitable. Chile declared war on 5 April 1879. Almost five years of war ended with the loss of the department of Tarapacá and the provinces of Tacna and Arica,
First Upper Peru campaign bulk of the royalist forces, while the center was hit by the soldiers of Pio Tristan. Many patriotic soldiers recruited at the Upper Peru surrendered or fled, and many of the recruits in La Paz switched sides during the battle. The Saavedrist Juan José Viamonte was instrumental in the defeat, by refusing to join the conflict. Although the casualties of the Army of the North were not substantial, it was left desmoralized and disbanded. The inhabitants of Upper Peru left them and welcomed the royalists back, so the army had to quickly leave those provinces. However, the resistance of Cochabamba