In 1836, he fought in the Texas War, where he was promoted to lieutenant colonel, and in 1838 in the Pastry War against France. In 1847, during the United States invasion, he gained fame at the Battle of Buena Vista. Also in 1847, he was given the military command of the state of Querétaro. In 1849, he became commander of the army ("jefe de la plana mayor del ejército"). In 1853, now a brigadier, he received command of the state of Mexico.