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. 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 Peru's War of Independence, fighting against the independence forces sent by Argentine general José de San Martín. 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. 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