Hampton raised the Hampton Legion, of which he was elected colonel, in 1861. He led them into action at the Battle of First Manassas, where he was wounded. After his recovery, he led a brigade into action during the Peninsula campaign. In July 1862, he was promoted to brigadier general. He served under Gen. J.E.B. Stuart's command until 1864. During his service, he was wounded at the Battle of Gettysburg, which contributed to his advancement to major general in August 1863. After the death of Stuart, Hampton succeeded him. He commanded the cavalry during the defense of Richmond, and throughout the Petersburg campaign. In February 1865, he received a promotion to lieutenant general for his service. He continued to serve until the surrender of the Army of Northern Virginia in April 1865.