He studied law and, after holding some minor judicial offices, was minister to New Granada in 1853. After his return, he occupied himself with plans for the establishment of a model penitentiary at Lima, which he was enabled to accomplish through the support of General Ramon Castilla. In 1860, Castilla made him director of public works, in which capacity he superintended the erection of the Lima statue of Simón Bolívar. He was also concerned in the reform of the currency by the withdrawal of the debased Bolivian coins.
In 1861, he published his great atlas of the republic of Peru, and, in 1868, the first volume of his history of Peru after the acquisition of her independence. A second volume followed, and a third, bringing the history down to 1839, was published after his death by his son.
In 1870, he was minister of justice and worship under President José Balta, but shortly afterwards retired from public life to devote himself to his great geographical dictionary of Peru, which was published in 1877. During the disastrous war with Chile, he sought refuge in Buenos Aires where he was made professor in the Colegio Nacional de Buenos Aires and where he wrote and published a history of the war (1884). He died on December 31, 1886.