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,
Trujillo, Peru only stable and productive area that could organize and lead the nascent republic. The department encompassed nearly half the country. For the efforts of its people in the war of emancipation, San Martín gave it the title of "Meritorious City Loyal to the Homeland". The municipality of the city, then called a "cabildo", was given the rank of "honorable". In 1823, after the creation of the Republic of Peru, the protectorate of José de San Martín was developed. Before royal troops took the city of Lima, the first President of Peru, Don José de la Riva Agüero, together with Sánchez