In the 1860s, the Spanish tried to regain control over Peru - without success.

An excerpt from the article 43 facts about Peru

They fought a war with Peru and Chile, but in 1879 they were forced to recognize the country's independence. Throughout history, Peru has also fought numerous wars with its neighbors. The most important of them was the so-called "Saltpetre War" (War of the Pacific) between Chile and the combined forces of Bolivia and Peru. The war ended with Chile's victory, which gained territory rich in mineral resources and cut off Bolivia's access to the Pacific. Peru then lost its Tarapaca province, which was rich in saltpeter. This defeat caused Peru's economic collapse.