Commissioned as a major in 1861, Anderson was present at the fall of Fort Sumter. In July, he received his first promotion - to brigadier general. He was in command of the city of Charleston until 1862, when he was transferred to the Army of Northern Virginia. He served in the Peninsula campaign of 1862 under Gen. James Longstreet. In July 1862, he received another promotion to major general. He commanded a division through the battles of South Mountain, Antietam, Fredericksburg, Chancellorsville, Gettysburg and Wilderness. After the Battle of Wilderness, he was promoted to lieutenant general in temporary command of Longstreet's corps. He served in the defense of Richmond, however, his division suffered heavily at the Battle of Sayler's Creek. He returned home before the surrender at Appomattox.