As an artillery battalion commander he distinguished himself in the Mexican–American War, serving under both Zachary Taylor and Winfield Scott, at Palo Alto, Resaca de la Palma, Monterrey, and Churubusco. He received brevet promotions from major through colonel for his service in these battles and ended the war as a lieutenant colonel in the Regular Army. In Mexico City, he was in charge of the police guard from the end of the war until 1848. During this time he became an original member of the Aztec Club of 1847.