In 1864, Peru, along with Bolivia, Chile and Ecuador, declared war on Spain when Spanish forces occupied the Guano rich Chincha Islands just off the coast of Peru. The Chincha Islands War lasted until 1866 after the Battle of Callao when Spanish forces bombarded the port city and returned to Spain. In August 1879, Spain officially recognized the independence of Peru and representatives of both nations signed a "Treaty of Peace and Friendship" in Paris and therefore establishing diplomatic relations.