 After the defeat of the Peru-Bolivian Confederation during the decade of the 1840s, anarchy in Peru became rampant.In 1843, during the government of Manuel Ignacio de Vivanco, Elías was named prefect of Lima.When Vivanco headed to southern Peru to confront the constitutionalist movement of Ramon Castilla, Elías was assigned the governorship of the northern Peruvian provinces.