Ramón Castilla y Marquesado (; 31 August 1797 – 30 May 1867) was a Peruvian caudillo who served as President of Peru three times as well as the Interim President of Peru (Revolution Self-proclaimed President) in 1863. His earliest prominent appearance in Peruvian history began with his participation in a commanding role of the army of the Libertadores that helped Peru become an independent nation. Later, he led the country when the economy boomed due to the exploitation of guano deposits. Castilla's governments are remembered for having abolished slavery and modernized the state.

He assumed the presidency for the first time after general Domingo Nieto's death for a short period in 1844, then in 1845 until 1851, again from 1855 to 1862 and, finally, during a brief period in 1863.

Ramón Castilla

First years

Castilla was born in Tarapacá (then part of the Viceroyalty of Peru), the second son of Pedro Castilla, of Spanish-Argentine origin, and Juana Marquezado de Romero, who was of part Aymara descent. In 1807 he traveled to Lima at the age of 10 to study with his brother and later continued his education in Concepción, Chile, also helping his brother with his business. In 1817 he enrolled in the Spanish colonial army during the Peruvian War of Independence, fighting against the independence forces sent by Argentine general José de San Martín.

Ramón Castilla

Castilla became a prisoner of war, but managed to escape and returned to Peru in 1821, deserting the Spanish Army and offering his services to José de San Martín, who enrolled him in the Patriot Army with the rank of lieutenant (a rank he had held with the Spanish Army). When San Martin resigned as "Protector of Peru", Castilla sided with José de la Riva Agüero, who in turn shortly became president in 1823.

Ramón Castilla

In 1824, when the Peruvian Congress named Simón Bolívar dictator or "Liberator of Peru", Castilla joined Simon Bolivar's army, fighting in the decisive Battle of Ayacucho, which helped Peru gain its independence from Spain. In 1825 Bolivar named him as governor of his native province of Tarapacá. In 1833, Castilla married Francisca Diez Canseco.

Anarchy: Castilla and Nieto

In 1839 Castilla beside the Chilean general Manuel Bulnes decided the victory of the Restorative Army in the battle of Yungay (War of the Confederation) and was named Minister of War and Minister of Finance in 1839 under Agustín Gamarra. Under the latter post, Castilla was responsible for Peru's first lucrative guano exportation. Meanwhile, president Gamarra had been harboring intentions of annexing Bolivia back to Peru and, in 1841, he led an invasion army to Bolivia, only to be defeated and killed by the army of José Ballivián during the Battle of Ingavi, leaving Peru without a leader. During that year various infights among caudillos occurred who constantly proclaimed themselves Presidents. Manuel Menéndez, then Vice President, assumed the presidency, but was overthrown by a coup d'état led by Juan Crisóstomo Torrico in 1842.

Soon after, Castilla, along with Domingo Nieto, overthrew Manuel Ignacio de Vivanco during the Battle of Carmen Alto. Nieto assumed the presidency but died a few months later. Castilla assumed the position on 17 February 1844 until 11 December of that year. After defeating the other caudillos around the country, Castilla reinstated Menéndez as president, in order to achieve a constitutional transition to democracy.

President of the Republic

In 1845, Castilla won the Peruvian presidential elections and was sworn in in April of that year. During this time, the guano export boom was rapidly expanding, largely due to treaties signed with the British company Antony Gibbs, which had commercialized the guano trade in Europe. Important urban projects began during this period, too, such as the first railroad from Lima to Callao, which helped in the transportation of guano from the production centers ready to be shipped abroad.

After six years in power, Castilla was succeeded by José Rufino Echenique. In 1854, however, another rebellion was led in Peru's second-largest city, Arequipa, by Castilla himself, who was largely urged by other Peruvian liberals to help in the suppression of slavery in the country.

On 3 December 1854, in the city of Huancayo, an abolition of slavery law was passed. As this law was being applied, Castilla confronted and defeated Echenique in the Battle of La Palma on 5 January 1855.