The Peru-Bolivian Confederation was a short-lived state that existed in South America between 1836 and 1839. The country was a loose confederation between the states of Peru, divided into the Republic of North Peru and the Republic of South Peru, and Bolivia, with the capital located in Tacna. The Peru-Bolivian Confederation's formation was personally influenced by Marshal Andrés de Santa Cruz, the President of Bolivia, who served as the first and only head of state under the title "Supreme Protector". The Peru-Bolivian Confederation was opposed by neighboring countries from its inception, particularly Chile and Argentina, as a potential military and economic threat, and for its support for dissidents in exile. The War of the Confederation was triggered shortly after its formation when Chile and Argentina independently invaded the country. Argentina was defeated in 1837, but a combined force of Chile and North Peruvian dissidents known as the United Restoration Army were victorious at the Battle of Yungay in January 1839, which de facto ended the confederation as Peru and Bolivia were restored as independent states, and Santa Cruz fled into exile. The Peru-Bolivian Confederation was officially declared dissolved on August 25, 1839, by General Agustín Gamarra after his appointment as President of Peru.. How many years did the Peru-Bolivian Confederation last?