During the Mexican–American War, Brannan was in the battles of Vera Cruz, Cerro Gordo, La Hoya, Contreras and Churubusco. He was brevetted to captain for gallantry for Contreras and Churubusco. He was severely wounded during the battle for Mexico City.