Ramón Castilla y Marquesado (; 31 August 1797 – 30 May 1867) was a Peruvian caudillo who served twice as President of Peru, first in 1845–1851, and then in 1855–1862. He also led a military junta in 1844, and was de facto interim president for a couple of days in April 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 began his military career in the royalist army, participating in the Battle of Chacabuco. Taken prisoner after the battle, he was taken to Buenos Aires where he obtained permission to leave the country and returned to Peru. Reinstated in the Royal Army of Peru, he joined the independence cause in early 1822. He organized and served in the cavalry of the Peruvian Legion, distinguishing himself at the Battle of Ayacucho. He continued his military and political career, holding high public offices such as sub-prefect of his native Tarapacá and prefect of Puno during the administrations of Agustín Gamarra and Luis José de Orbegoso.

His first constitutional government was notable for the country's institutional stability after a long period of anarchy, the organization of the Peruvian state, and the economic boom fueled by revenues from the guano deposits. He led the liberal revolution of 1854 and decreed the abolition of the indigenous tribute and the end of slavery.

Early life Castilla was born in TarapacáKuss, pg 147 (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.Searle & Rivington, pg 35 During his childhood, he helped his father as a woodcutter, and made trips to the desert to collect dry carob tree branches.

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.

Military career

Spanish American Wars of Independence In 1812, Castilla enlisted, along with his brother Leandro, in the Royal Army of Peru. He actively participated in the campaigns against the Chilean War of Independence. After the defeat of the insurgents, he received his commission as a full cadet in the Dragoons of the Frontier cavalry regiment in Santiago (1816). At the age of twenty, as an escort officer to Brigadier Francisco Marcó del Pont in the Spanish army, he suffered the defeat at the Battle of Chacabuco on 12 February 1817, and was forced to retreat, being captured at the Las Tablas hacienda, near El Quisco.

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.

He was incorporated as a cavalry second lieutenant into a squadron of the Peruvian Legion of the Guard (later called the Junín Hussars), which was then being formed. Ramon Castilla worked intensively in the recruitment and training of volunteers. After San Martín's resignation as Protector of Peru, he placed himself at the service of the new government established in Lima. For his services in the organization of Peruvian troops, he was promoted to major and then to lieutenant colonel of cavalry.

He served loyally under President José de la Riva Agüero until the latter attempted to negotiate with the Spanish, at which point he supported the rebellion of Colonel Antonio Gutiérrez de la Fuente, who imprisoned the president on 25 November 1823.  Castilla was commissioned to arrest General Ramón Herrera, the army commander, who was in Santa.

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 y Corbacho.

Participation in the new republic As sub-prefect of Tarapacá, he opposed Bolívar's Constitution for Life and the political project of creating the Federation of the Andes. When the Congress meeting failed, it was decided that the Constitution would be approved through the Electoral Colleges. All approved it, except for the one from Tarapacá, presumably due to Castilla's opposition (1826).

With the end of Bolivarian influence and the establishment of José de la Mar's government, and faced with the imminent conflict with Gran Colombia, he was transferred to Arequipa with the mission of organizing the reserve; there he uncovered a conspiracy plotted by supporters of Bolivian President Andrés de Santa Cruz to secede the southern departments in August 1829, and acted as prosecutor in the case brought against them.

Promoted to colonel, he went to Lima in 1830. President Agustín Gamarra appointed him his aide-de-camp, and together they marched to Cusco to fight the federalist revolution started by Colonel Gregorio Escobedo, which was suppressed that same day by the people of Cusco themselves. Nevertheless, Castilla continued to the Bolivian border and assumed command of the reserve division garrisoning the region. There was then a serious threat of armed conflict with Bolivia, but for the time being it was resolved peacefully.

Back in Lima, Castilla criticized the policies of President Gamarra and was implicated in the conspiracy of Congressman Iguaín. Arrested on 1 January 1832, he was first imprisoned in the Real Felipe Fortress and then on a pontoon anchored in Callao. It is said that he unwittingly betrayed Captain Felipe Rossel, a trusted officer of the president, who was eventually executed. While imprisoned, Castilla fell ill and was transferred to the Santa Ana Hospital, from where he escaped, embarking for Chile in May 1833. His trial was suspended, and he was later acquitted.

In November 1833, he reappeared in Tarapacá, where he supported the proclamation of General Luis José de Orbegoso as provisional president. He then went to Arequipa and, when General Pedro Bermúdez's rebellion broke out, he remained loyal to the government and participated in the campaign against the southern rebels, who were defeated at the Battle of Cangallo. With internal peace restored after the Embrace of Maquinhuayo, he was promoted to Brigadier General.

In Chile, Castilla joined the group of Peruvian émigrés who opposed the Peru–Bolivian Confederation project and hoped to return with the support of a Chilean expeditionary force, which the all-powerful Chilean minister Diego Portales was meticulously assembling. However, a group of Chilean officers opposed this expedition and mutinied in Quillota on 3 June 1837, arresting Portales. Castilla joined the Chilean forces sent to quell the uprising, commanding the Junín Cuirassiers, a corps of 150 Peruvian volunteers. The mutineers were defeated at the Battle of Cerro Barón, but Portales was killed; nevertheless, the Chilean government's war plans continued.

From Chile, the so-called Restorative Expeditions were organized against the Confederation, composed of allied Chilean and Peruvian armies, which Castilla joined. In the first expedition, Castilla was head of the Peruvian Legion and prefect of Arequipa. He had serious disagreements with Manuel Ignacio de Vivanco, the leader of the Peruvian expeditionaries. This expedition failed in Arequipa, and Castilla, along with the rest of the restorationists, returned to Chile.

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.

Political career

First presidency

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. The main source of guano came from the Chincha Islands 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.

The discovery and commercialization of guano united sectors of the elite around the formation of a stronger state capable of administering these resources. Castilla established an accounting office that produced Peru's first official budget in 1847, reopened the Bellavista Military Academy to professionalize the army, and repressed several uprisings in 1848 and 1849. In 1851, he oversaw the construction of South America's first railway, linking Lima with the port of Callao.

Castillas government was moderate and progressive. He pursued a policy of concord, repealing the expatriation decrees issued against the defeated members of the Confederation. In 1847, he even restored their rights, having omitted from the outset to persecute the supporters of Vivanco's regime; moreover, he employed competent men in administrative positions.

When Castilla came to power, Peru had a substantial internal and external debt, which he resolved to pay with the revenues from guano. The internal debt was owed to individuals who had contributed, in kind or in cash, to the War of Independence and during the subsequent wars and revolutions. The external debt was contracted with several countries: England and Gran Colombia, incurred during the independence struggle; Chile, for the expenses of San Martín's liberating army and the restoration armies; Spain, as stipulated in the Capitulation of Ayacucho; and also France and the United States.

By laws given in 1847, 1848 and 1850, Castilla ordered the payment of the internal debt, a payment known as the "consolidation of the internal debt",  which would cause a tremendous corruption scandal in the following government of Echenique.