The American Civil War was a major war between the United States, the Union, and eleven southern slave states that declared their secession and formed the Confederate States of America under President Jefferson Davis. The Union, led by President Abraham Lincoln, opposed the expansion of slavery and rejected any right of secession. Fighting began on April 12, 1861, when Confederate forces attacked Fort Sumter in South Carolina. Robert E. Lee's invasion of the North was repulsed at the Battle of Gettysburg in Pennsylvania in July 1863, the turning point of the war. Ulysses S. Grant commanded the Union forces until 1865, when the Confederacy collapsed and Lee surrendered to Grant at Appomattox Court House in Virginia. Total Union casualties were 650,000 and total Confederate casualties were 134,00.