The Battle of Gettysburg () was a three-day battle in the American Civil War, which was fought between the Union and Confederate armies between July 1 and July 3, 1863, in and around Gettysburg, Pennsylvania. The battle, won by the Union, is widely considered the Civil War's turning point, leading to an ultimate victory of the Union and the preservation of the nation. The Battle of Gettysburg was the bloodiest battle of both the Civil War and of any battle in American military history, claiming over 50,000 combined casualties. Union Major General George Meade's Army of the Potomac defeated attacks by Confederate General Robert E. Lee's Army of Northern Virginia, halting Lee's invasion of the North and forcing his retreat.
After his success in the Battle of Chancellorsville in Spotsylvania County, Virginia in May 1863, Lee led his Confederate forces through Shenandoah Valley to begin the Gettysburg campaign, his second attempt to invade the North. With Lee's army in high spirits, he intended to shift the focus of the summer campaign from war-ravaged Northern Virginia in the hopes of penetrating as far as Harrisburg or Philadelphia, which he hoped would convince northern politicians to end the war. President Abraham Lincoln initially prodded Major General Joseph Hooker into pursuing Lee, then relieved him of command just three days before the Battle of Gettysburg commenced, replacing him with Meade.