He spent some years in the Regiment Fijo de Bandera, but then decided to pursue a career in civil law.
After the proclamation of independence in 1821, he opposed the union of the province of El Salvador with the Mexican Empire.
As political chief of San Salvador he organized the civic militia during a time of threat to the capital by an invasion from Guatemala.
On the fall of Emperor Agustín de Iturbide, and of the Mexican Empire itself, El Salvador regained sovereignty.
During this period (in 1826), El Salvador broke relations with the federal government in Guatemala City.