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 as the Bolivian Republic, 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 25 August 1839, by General Agustín Gamarra after his appointment as President of Peru. Historian Jorge Basadre frames the confederation as part of a period of "determination of the nationalities" in western South America. Background During colonial times, the territory comprising the Audiencia de Charcas, also known as Alto Perú, now Bolivia, was an integral territory of the Spanish Viceroyalty of Peru from its creation. In 1776, it was administratively severed and became a province of the newly created Viceroyalty of the Río de la Plata. Still, for geographical and historical reasons, it always remained closer to Lima than to its administrative capital, Buenos Aires, in present-day Argentina. The Peru–Bolivian Confederation was the only effective attempt to unite them. This territory achieved independence in 1825. At this point in time, a union with Peru was widely supported. Instead, the new Republic of Bolivia, named after Simón Bolívar, who had liberated the territory and destroyed the last remnants of the Spanish army, was born, with Bolívar as the first president. Political unrest and turmoil forced Bolívar to return to Colombia very soon afterwards, leaving Antonio José de Sucre in charge. The plan for reuniting Peru and Bolivia did not fade away. Chaos in Bolivia Marshal Sucre was elected