At the beginning of the war, he served in various staff positions, before becoming a colonel and chief-of-staff of the Army of Virginia under General John Pope, where he saw action in the Battle of Cedar Mountain, the Second Battle of Bull Run, and the Battle of Chantilly. He later served as assistant chief-of-staff of the Army of the Potomac, being engaged in the battles of South Mountain and Antietam. In December 1862, he was assigned to staff duty in Washington, D.C.. In February 1865, he was named adjutant general of the Army of the Potomac under General George Meade, and took part in the Battle of Hatcher's Run.