In May 1861, Lee resigned his position in the U.S. Army to join the Confederate army in the rank of 1st Lieutenant. He served at First Manassas. Shortly after, in August, he became lieutenant colonel of the 1st Virginia cavalry. In 1862, during the Peninsula campaign, he was promoted to brigadier general. In 1863, after the Battle of Gettysburg, he is promoted to major general. Lee played a large role in the Confederate cavalry command structure. Lee distinguished himself at the Battle of Spotsylvania Courthouse. In January 1865, Lee is put in command of the Cavalry Corps until the surrender at Appomattox.