At the start of the Civil War, Geary raised the 147th and 28th Pennsylvania Infantry regiments and became colonel of the latter. Commanding the district of the upper Potomac River, he was wounded and captured near Leesburg, Virginia, on March 8, 1862, but was immediately exchanged and returned to duty. He was promoted to brigadier general and the command of a brigade in Maj. Gen. Nathaniel Banks's corps, which he led in the Shenandoah Valley against Thomas J. "Stonewall" Jackson. His brigade joined Maj. Gen. John Pope's Army of Virginia in late June. He led it at the Battle of Cedar Mountain on August 9, 1862, where he was seriously wounded in the arm and leg. He returned to duty on October 15 as the division commander; the corps was now part of the Army of the Potomac, designated the XII Corps, under the command of Maj. Gen. Henry W. Slocum.
Geary's division was heavily engaged at Chancellorsville, where he was knocked unconscious as a cannonball shot past his head on May 3, 1863. (Some accounts state that he was hit in the chest with a cannonball, which seems unlikely.)
At the Battle of Gettysburg, Slocum's corps arrived after the first day's (July 1, 1863) fighting subsided and took up a defensive position on Culp's Hill, the extreme right of the Union line. On the second day, heavy fighting on the Union left demanded reinforcements and Geary was ordered to leave a single brigade, under Brig. Gen. George S. Greene, on Culp's Hill and follow another division, which was just departing. Geary lost track of the division he was supposed to follow south on the Baltimore Pike and inexplicably marched completely off the battlefield, eventually reaching Rock Creek. His two brigades finally returned to Culp's Hill by 9:00 p.m. that night, arriving in the midst of a fierce fire fight between a Confederate division and Greene's lone brigade. This embarrassing incident might have damaged his reputation except for two factors: the part of the battle he was supposed to march to join had ended, so he wasn't really needed; and, because of a dispute between army commander Maj. Gen. George G. Meade and Slocum over the filing of their official reports, little public notice ensued.
After the war, Geary served two terms as the Republican governor of Pennsylvania, from 1867 to 1873. He established a reputation as a political independent, attacking the political influence of the railroads and vetoing many special interest bills.
On February 8, 1873, less than three weeks after leaving the governor's post, Geary was fatally stricken with a heart attack while preparing breakfast for his infant son in Harrisburg, Pennsylvania. He was 53 years old. He was buried in Harrisburg with state honors in Mount Kalma Cemetery.