After the dissolution of the Peruvian – Bolivian Confederation led by Andrés de Santa Cruz, President Gamarra, as provisional president, convened a General Congress in Huancayo, the same one that gave the Conservative Constitution of 1839. Obsessed with the idea of reuniting again to Bolivia with Peru, invaded that country, but was defeated in the battle of Ingavi in 1841.
The Gnral. José Ballivián and the Bolivian Army had the opportunity to counterattack and invade Peruvian territory, occupying southern Peru from Moquegua to Tarapacá. Then open several fronts of struggle in southern Peru.
Colonel Manuel de Mendiburu, who was a military commander of the South, returns from Lima to organize the Peruvian resistance.
The Peruvian Army organizes the resistance, defeats and expels the invading Bolivian troops based in Tarapacá, Arica, Tacna, Moquegua and Puno in various battles such as the Battle of Tarapacá in 1842, Altos del Chipe, combat of Motoni and the combat of Orurillo, where they subsequently began the withdrawal of Bolivian forces that occupied Peruvian territory, threatening again Bolivia to suffer an invasion. At the end of the contest the Treaty of Puno was signed on June 7, 1842.
With the first election of Ramón Castilla in 1845, the Peruvian Republic found a relative inner peace and was able to organize its political and economic life. It was up to Castilla to definitively abolish slavery and the death penalty, and established policies to promote the extraction and export of natural fertilizers (guano from islands) that would begin an era of prosperity in the country.88 The first railroads and street lighting Gas arrived in Peru during this period, during its second government it promulgated the Constitution of 1856 (Liberal) and the Constitution of 1860 (Conservative), reorganized the postal services and the public career.
Internally, the impulse given to the development of the Amazon and to the equipment of the armed forces continued, as well as the promotion of material progress with the adoption of great technical advances such as the telegraph and gas lighting.
Also, Castilla had an intense political activity in the international field. He strongly opposed the intrusions of the European powers in America (Santo Domingo, Mexico), calling for American unity. On the other hand, he faced a victorious war with Ecuador (1858-1860).
During its mandate the Peruvian-Ecuadorian War (1858-1860) took place, which ended with the subscription of the Treaty of Mapasingue, in itself the war arose because in 1857 the Ecuadorian government celebrated a contract of adjudication of land with its British creditors in the Ecuadorian lands, especially in Canelos and Quijos, which Peru through its minister Juan Celestino Cavero claimed that those territories belong to Peru, the Peruvian congress authorized the president of that time; Mariscal Ramón Castilla, to use any method that is convenient to resolve this fief, including the war.
Castilla ordered a blockade of the entire Ecuadorian coast (October 26, 1858). Guayaquil began to suffer the ravages of the blockade which the commander of the plaza Gral. Guillermo Franco Herrera manages to communicate with the Marshal Castilla to start negotiations and lift the blockade. As a result, Castilla signs the decree to lift the blockade on the entire Ecuadorian coast to begin a final settlement.
Castilla could not give solutions and start a conversation since Ecuador was mired in a civil war, gave a period of 30 days for there to be a solution to this internal conflict; When the war did not take place, restarting the conflict with the re-activation of the blockade to the Ecuadorian coast, the Peruvian squadron appeared in the port of Guayaquil on November 12, 1859, allowing the landing of Peruvian troops, thus the 3 northern governments in dispute were unified (Guayaquil, Azuay and Loja) under Guillermo Franco. Castilla decided to carry out the negotiations, resulting in the Treaty of Mapasingue signed on January 25, 1860, which made valid the Royal Decree of 1802, canceled the contract with the English, and established the organization of a commission to indicate the final limits between the two nations. The libertarian forces, with García Moreno of Quito and General Juan José Flores in command, managed to defeat Franco’s army and enter Guayaquil. García Moreno annulled the Treaty of Mapasingue.
On the other hand, Peru, under the government of Miguel de San Román; the Peruvian congress disapproved it in 1863. This generated the following episode to this bloody conflict: “the War of 1941”.
In 1864 a Spanish expedition occupied the Chincha Islands (producers of guano) and sparked an international incident of great consequences in Peruvian internal politics, which led to a coup d’état against President Juan Antonio Pezet, the government of Mariano Ignacio Prado and the declaration of war on Spain After the battle of Callao on May 2, 1866, the Spanish Armada withdrew from Peru.The government of José Balta y Montero was prodigal in infrastructure works (construction of the Central Railroad) although in He already perceived the first signs of excessive government spending.
In the aftermath of his government, the election, for the first time, of a civilian president, Manuel Pardo y Lavalle, led to a military uprising that ended in the murder of Balta and the furious reaction of the population of Lima (which executed the usurpers), this is what Jorge Basadre called First Militarism, Pardo and Lavalle implemented important liberal reforms in the organization of the state. However, the main source of resources of the state, the guano, over-exploited, began to run out and it was inevitable an economic crisis that the successor of Pardo, the already elderly Mariano Ignacio Prado had to face, in the middle of a virtual bankruptcy of the State.
By 1859 some 41,000 Peruvians had been killed in the constant civil wars that shook the country since 1829. Thanks to the money from the sale of guano, Peru began to modernize with various public works such as railroads; the civil and military bureaucracy grew; the Indians stopped paying tribute and the slaves reached their freedom; The migration policy of Germans, Austrians, Irish and Italians began.
On April 5, 1879, Chile declared war on Peru, unleashing the Pacific War. The casus belli were the confrontation between Bolivia and Chile for a tax problem in which Peru was compromised by the Treaty of Defensive Alliance signed with Bolivia in 1873. However, Peruvian historiography is unanimous in holding that the root cause of This war was the ambition of Chile to seize the saltpeter territories and guaneros of southern Peru.In the first stage of the war, the naval campaign, the Peruvian navy repelled the Chilean attack until October 8, 1879, the day in the one that fought the Angamos naval battle, where the Chilean Navy with its Cochrane ships, Blanco Encalada, Loa and Covadonga cornered the monitor Huáscar, the main ship of the Peruvian Navy commanded by the Admiral AP Miguel Grau Seminario, who died in the fray and since then became the greatest hero of Peru.
After defeating the Peruvian squadron, Chile began the terrestrial campaign of the war. This began with the disembarkation of Pisagua and was developed during four years (including the occupation of Lima), until after the Grito de Montán, the government of Miguel Iglesias, signed the Treaty of Ancón that put an end to the war, in spite of the opposition of the government of Lizardo Montero and the resistance in the Peruvian highlands commanded by Andrés Avelino Cáceres, who foresaw the near exhaustion of the Chilean forces to defeat them.