When South Carolina seceded from the Union in December 1860, Gregg helped organize the 1st South Carolina Volunteers, and served as the regiment's first colonel. He became a brigadier general and served in A. P. Hill's "Light Division". His brigade played a prominent role in Hill's assault on the Union lines at the Battle of Gaines' Mill. Gregg gained prominence at the Second Battle of Bull Run when his men repulsed six Union assaults, and he served in Robert E. Lee's Maryland Campaign. At Antietam he was wounded in the thigh by the same bullet that killed Brig. Gen. Lawrence O'Bryan Branch.