Peruvian territory was home to the vast Inca Empire, extending from northern Ecuador to central Chile. After the conquest of the empire by the Spanish, the Inca population decreased from an estimated nine million in the 1520’s to around 600,000 in 1620, mainly because of infectious diseases such as smallpox. Although not an organized attempt at genocide, the results were similar.
Lima, founded in 1535 by Pizarro, became the base for the Spanish royal authority over their South American territories: the Viceroyalty of Peru. Apart from a few rebellions early in the eighteenth century, the Spanish-American oligarchy in Peru remained mostly loyal to the Spanish crown. The Viceroyalty of Peru would be the last stronghold of the Spanish dominion in South America. Peru’s movement towards independence was launched by an uprising of landowners and their forces, led by José de San Martín of Argentina and Simón Bolívar with his close friend Antonio José de Sucre, both from Venezuela. San Martín, who had displaced the Royalists of Chile some years before, led the military campaign. The independence of Peru from Spain was consolidated after the Battle of Ayacucho in 1824 in Upper Peru. The new independent republic was renamed Bolivia, in honour of Bolívar.

The creation in 1836 of the Peru-Bolivian Confederation caused great alarm in the neighbouring countries. The potential power of this alliance aroused the opposition of Argentina and Chile. The resulting war between the Confederation on one side and Chile, Peruvian dissidents and Argentina on the other, was fought mostly in the territory of Peru, and ended in 1839 with the defeat and consequent dissolution of the Peru-Bolivian Confederation. This was also a turning point in Bolivian history. Coups and short-lived constitutions would dominate Bolivian politics for nearly 60 years. The War of the Pacific (1879–1883) demonstrated Bolivia’s military weakness, when it lost its seacoast and the adjoining rich nitrate fields to Chile.