After independence, Peru and its neighbors engaged in intermittent territorial disputes. An attempt to unite Peru and Bolivia was made during the period 1836–1839 by Bolivian President Andres de Santa Cruz when the Peru-Bolivian Confederation came into existence. Severe internal opposition led to its demise in the War of the Confederation which dovetailed into a Peruvian attempt to annex Bolivia by Agustín Gamarra that ultimately failed and turned into a protracted war. Between 1857 and 1860 a war broke out against Ecuador for the disputed territories in the Amazon. The Peruvian victory in the war prevented the Ecuadorian claims to settle in the area.