In 1829 Peru broke away from Bolívar’s Greater Colombia. A period of bloody civil wars followed, in which conservatives and liberals faced each other. The Bolivian dictator A. Santa Cruz intervened in the turmoil in 1836 by uniting Peru with Bolivia into a federal state. He was overthrown after his defeat in the war against Chile (1839), and Peru regained its independence. General R. Castilla pushed back internal anarchy as President (1845–51, 1855–62). He introduced compulsory schooling and abolished the “Indian tribute”. With the rule of Castilla an economic upswing began, the main supporters of which were foreign, especially British, companies. The main sources of Peruvian wealth were now the guano of the coastal islands and the saltpetre deposits of the Atacama desert in the southern provinces. The occupation of some islands by Spanish ships (1864) prompted Peru to declare war on Spain (1866). In 1879 Peru became involved in the saltpeter war against Chile. The Chileans occupied Lima in January 1881; In the Peace of Ancón (October 20, 1883), Peru had to cede its saltpetre provinces (Tarapacá, Arica and Tacna) to Chile.
After the defeat in the Saltpeter War, British and North American companies regained dominant influence. The presidents N. Piérola (1895–99) and José Pardo y Barreda (1904–08, 1915–19; * 1864, † 1947) succeeded in consolidating the interior of Peru. After a coup d’état, AB Leguía took over the post of President for the second time in 1919. He achieved a foreign policy success on the Tacna-Arica question: In the Treaty of Lima (June 3, 1929), Chile returned the province of Tacna to Peru. Peru also received a free port in Arica, which remained with Chile, and monetary compensation of US $ 6 million.
Against the background of the global economic crisis and after the fall of Leguías (1930), a phase of internal unrest followed. Due to the influence that the Alianza Popular Revolucionaria Americana (APRA) gained under V. R. Haya de la Torre, the internal political contradictions intensified. Oriented towards socialism and anti-imperialism, this movement sought to implement land reform and to improve the political, social and cultural position of the indigenous people in Latin America. The suppression of APRA drove its leaders and supporters underground.
In 1932, according to usaers, the war between Peru and Colombia over the Leticia tip broke out after Peruvian troops had occupied the Colombian city of Leticia; after mediation by the League of Nations, it was settled by returning Leticia to Colombia. In the Second World War, from February 1942, Peru considered itself at war with Germany; In 1940 an armed conflict broke out between Peru and Ecuador when Peru claimed the Ecuadorian entrances to the upper Amazon. The dispute was decided at the Conference of Rio de Janeiro (1942) in favor of Peru, which was awarded most of the Ecuadorian Oriente.
In 1945, José Luis Bustamante y Rivero (* 1894, † 1989) was elected President as representative of the Liberals. He brought Haya de la Torre into his government, but was forced to resign in October 1948 by General Manuel Arturo Odría Amoretti (* 1897, † 1974) after domestic political difficulties; the general, appointed president in July 1950 after two years as leader of a military junta, cracked down on the APRA, but largely stabilized the economy and currency. The growing resistance to his military dictatorship forced him to allow free elections, in which Manuel Prado y Ugarteche (* 1889, † 1967) on June 17, 1956was elected President for the second time (first time 1939-45). Against the resistance of the rich rural aristocracy, Prado was unable to implement his reform plans. In the 1962 presidential election, Haya de la Torre received the most votes as the APRA candidate; but the military did not recognize the election result. President Prado, who refused to cancel the election, was overthrown on July 18, 1962.
In the new elections carried out by the military junta on 9.6.1963, F. Belaúnde Terry (Acción Popular) won. The worsening situation in agriculture, which led to peasant uprisings and acts of terrorism, countered Belaúnde Terry with an agrarian reform in 1964, which only resulted in the expropriation of around 8% of the total farm area. On October 3rd, 1968, Belaúnde Terry was overthrown by a military coup and the commander in chief of the armed forces, General J. Velasco Alvarado, appointed as the new President. He expropriated North American oil companies and carried out radical structural reforms, including included the nationalization of some industry and agriculture and foreign banks (1970). Further nationalization measures and the expropriation of large daily newspapers (1974) followed. When Francesco Morales Bermúdez (* 1921) came to power in a coup on August 29, 1975, many measures in favor of the private sector were withdrawn. In 1976/77 Peru was in a state of emergency for several months. Economic hardship and domestic political tensions, exacerbated by the escalation of violence between the state and guerrillas since the early 1980s, led Peru into a serious crisis. Belaúnde, again successful in the 1980 elections, failed to consolidate the country. His successor A. García Pérez (APRA), President 1985-90, failed because of inflation, unemployment and the conflict with the guerrilla organizations Sendero Luminoso (SL) and Movimiento Revolucionario Tupac Amaru (MRTA), which plunged the country into civil war a total of around 70,000 fatalities. The guerrillas allied themselves with the drug mafia, and the army and police units fighting them are guilty of serious human rights violations.