Following the death of President Agustin Gamarra (1785-1841) at Ingavi in the Peruvian-Bolivian War of 1841, Peru became torn by civil war inm 1842. In early 1843, Manuel Ignacio Vivanco (fl. 1840s), calling himself "The Regenerator," seized power and ruled the country as a dictator with the support of the army; he ignored the 1839 constitution, failed to convene the Peruvian congress, and punished disloyalty with the firing squad. Beginning in 1844, opposition to Vivanco entered in southern Peru, where Ramon Castilla (1797?-1867) and others led armies in support of the former constitution. Constitutionalist troops seized control of Peru's capital, Lima, while Vivanco was absent. At the Battle of Carmen Alto on July 22, 1844, constitutionalist armies under the direction of Castilla won against Vivanco's forces, compelling Vivanco to flee into exile. Factional strife continued until Castilla was elected president in 1845 and brought some order to Peru.