The Chincha Islands War (1864-1866) was a conflict between Spain and its former colonies Peru and Chile. Spain recognized Chiles independence and they had a nice relationship, but they didnt recognize Perus independence and wanted to charge them unpaid fees. When Peru didnt want to pay them, Spain took over the Chincha Islands, a bunch of islands containing rich deposits of guano.
When Chile refused to supply the Spaniards with coal for their ships, they took the fuel by force, leaving them at war. Four months later, Peru allied with Chile and also declared war on Spain. Later, Ecuador and Bolivia entered the war at the side of their neighbors.
It was mostly a naval conflict, with one failed landing attempt by Spain, and it ended with the battered Spanish fleet retiring. However, the damage done to the Peruvian fleet and the Chilean commercial port of Valparaíso was catastrophic.