During his terms, Honduras and Nicaragua were states within the Federal Republic of Central America.
Herrera was an uncle of the Liberal Central American general Francisco Morazán.
From a land-owning family, Herrera studied at the University of San Carlos of Guatemala, where he earned a law degree and came in contact with the liberal ideas of the French Revolution.
He was a tutor of his nephew, General Morazán.
In 1820 he occupied his first public office, as secretary of the town government of Tegucigalpa.
On 16 September 1824 he became the first head of state of Honduras, after the independence of Central America from Spain and from Mexico.
During his term he decreed the first territorial subdivisions of Honduras, creating the departments of Comayagua, Tegucigalpa, Santa Bárbara, Yoro, Olancho and Choluteca (department).
Herrera was sent as a prisoner to Guatemala, where he remained until 1829.
Thereafter he was elected head of state of Nicaragua, taking office on 12 May 1830.
He exercised this office until November 1833, relying on the support of General Morazán.
He tried to implement various Liberal reforms, but unsuccessfully, due to the opposition of the clergy.
In 1835 he was elected head of state of El Salvador, but he declined the office.
In 1838 he retired from politics, working as a teacher in the city of San Vicente, El Salvador.