during the republican era, foreign companies were invited to exploit the deposits. These companies were assigned the area between the Loa and Paposo rivers by minister Hilarión Fernández on March 28, 1842. The illegal exploitation of guano was prosecuted by the Supreme Court of Bolivia, and even by British tribunals. On October 31 of that same year, Chile declared its ownership of all the guano deposits in the Atacama Province. A year later, the Chilean government officially created the Province of Atacama. Casimiro Olañeta was sent to negotiate with Chile, however, negotiations never took place. In 1847, Chilean guaneros penetrated Bolivian territory as far back as the Mejillones Bay, even building a fort there and placing the Chilean flag on top. The Prefect of Cobija destroyed the fort and dispersed the guaneros, maintaining sovereignty for a decade until it was challenged again. In 1857, José Goñi Prieto, at the helm of the Esmeralda, seized the Mejillones Bay. Negotiations were opened between the two governments, ending on September 2, 1861, with no results. Retaking Mejillones became a priority of the government, such that the National Assembly which met in Oruro in 1863 authorized the declaration of war with Chile if negotiations reached a dead end. Chincha Islands War and the 1866 Treaty On April 14, 1864, the Chincha Islands, off the coast of Peru, were occupied by Spanish sailors. The Spanish Crown claimed that, since it had not recognized the independence of Peru, only a truce had stopped hostilities for the past decades. These guano-rich islands were coveted by the Spanish government, and their occupation led to a temporary ceasefire in the hostilities between Chile and Bolivia. Peru and Chile proclaimed an alliance against the Spanish invaders, known as the American Union. This conflict against their former overlords became known as the Chincha Islands War. President Achá had been reluctant to join, since Spain had recognized Bolivian independence and the two countries had good relations ever since. The war would be a maritime one and, with the inferiority of the allied navy, the Spanish could only be defeated if they were starved and had no port to refuel and equip themselves. Bolivian neutrality provided the Spanish with said ports, threatening the American Union. As such, in 1866, the Chilean government sent Aniceto Vergara Albano to negotiate with Melgarejo. Reaching and agreement with Vergara, Melgarejo scrapped the casus belli against Chile, issued