Having assisted in the liberation of his country from Spanish rule (1812–13) he went on to aid Bernardo O’Higgins in the liberation of Chile (1817–18). He was also involved in gaining Peruvian independence, becoming Protector of Peru in 1821; he resigned a year later after differences with the other great liberator Simón Bolívar.