When war was declared against Mexico a few years later, he enlisted with his men as Company B of the 1st Pennsylvania Volunteers. His regiment was stationed at the Perote Castle to keep open the communication with Veracruz during its siege. He assisted in routing a force of guerillas at La Hoya, fought at Huamantla, Puebla, and Atlixco, entered the city of Mexico, and was finally stationed at San Ángel until the close of the war. He was mustered out of service with his company at Philadelphia on July 27, 1848, and the inhabitants of Schuylkill County, Pennsylvania, presented him with a commemorative silver and gold-plated sword.