Following the attack on Fort Sumter on April 12, 1861, on April 17, Virginia voted to secede from the United States and joined the Confederate States (though not officially doing so until May), and soon thereafter the Confederate government moved its capital from Montgomery, Alabama to Richmond.
The Confederate Congress shared quarters with the Virginia General Assembly in the Virginia State Capitol, with the Confederacy's executive mansion, the "White House of the Confederacy", located two blocks away. The Seven Days Battles followed in late June and early July 1862, during which Union General McClellan threatened to take Richmond but ultimately failed.
Three years later, on April 2, 1865, the Union Army under Ulysses S. Grant captured Richmond, and the state capital and Confederate capitals were briefly relocated to Danville. About 25% of the city's buildings were destroyed in a fire set by retreating Confederate soldiers, with Union soldiers putting out the fires as they entered the city.
[Source: Wikipedia]