Battle of Churubusco
As the Mexican–American War was beginning, O'Hara signed up for the U.S. Army on June 26, 1846. He held the positions of captain and quartermaster of volunteers under General Gideon J. Pillow as they advanced upon Mexico City, Mexico. For excellent conduct in the Battle of Contreras and the Battle of Churubusco, O'Hara was honored with the rank of brevet-major on August 20, 1847. He was honorably discharged on October 15, 1848. After the war ended in 1848, O'Hara returned to Washington, D.C. to continue his law practices until 1851.