In 1846, at the beginning of the Mexican–American War, Roberts was reappointed a first lieutenant, Mounted Rifles, in the Regular Army. He was promoted to captain in 1847, and saw action at Veracruz, Cerro Gordo, Contreras, Churubusco, and the capture of Mexico City, Matamoros and the Galajara pass. At Churubusco, he was brevetted major for leading an advance party of stormers. He received a further brevet, to lieutenant colonel in 1847 for gallantry during the war. After the close of hostilities, he served on the frontier and in Washington, D.C.