The Gettysburg campaign was a military invasion of Pennsylvania by the main Confederate army under General Robert E. Lee in summer 1863. The Union won a decisive victory at Gettysburg, July 1–3, with heavy casualties on both sides. Lee managed to escape back to Virginia with most of his army. It was a turning point in the American Civil War, with Lee increasingly pushed back toward Richmond until his surrender in April 1865. After his victory in the Battle of Chancellorsville, Lee's Army of Northern Virginia moved north for a massive raid designed to obtain desperately needed supplies, to undermine civilian morale in the North, and to encourage anti-war elements. The Union Army of the Potomac was commanded by Maj. Gen. Joseph Hooker and then by Maj. Gen. George G. Meade.
Lee's army slipped away from Federal contact at Fredericksburg, Virginia, on June 3, 1863. The largest predominantly cavalry battle of the war was fought at Brandy Station on June 9. The Confederates crossed the Blue Ridge Mountains and moved north through the Shenandoah Valley, capturing the Union garrison at Winchester, in the Second Battle of Winchester, June 13–15.