American Battlefield Trust’s map of the Civil War's Gettysburg Campaign from June 3 to July 1, 1863
After his victory at Chancellorsville, Robert E. Lee maintained the offensive initiative and made plans to move north into Pennsylvania. On June 3, Lee began to quietly move his army west from Fredericksburg towards the Shenandoah Valley. The campaign was almost undone on June 9 in a cavalry battle at Brandy Station, but Jeb Stuart’s Confederate cavalry held off attacking Union troopers.
General Richard Ewell’s corps, followed by A. P. Hill and James Longstreet, entered the Shenandoah Valley and moved north. Ewell won victories at Winchester, Martinsburg, and Stephenson's Depot in mid-June, eliminating Union resistance in the Valley. Stuart successfully screened Lee’s movement north by covering the mountain gaps near Aldie, Middleburg and Upperville. Stuart then departed on a long, looping raid around the Union army that deprived Lee of a valuable reconnaissance asset, losing contact with the infantry in the process.
Confederates crossed the Potomac River beginning on June 15. Federal commander Joseph Hooker moved north in pursuit of Lee, who arrived in Chambersburg, Pennsylvania on June 27. The next day, Ewell’s advance elements reached the Susquehanna River at Wrightsville, Pennsylvania. Also that day, at Frederick, Hooker was replaced with George G. Meade who continued pushing the army north. Learning that Federal forces were closing in, Lee ordered his army to concentrate on June 29, using the road network that converged on Gettysburg. Union cavalry tangled with Stuart at Westminster and Hanover, preventing him from rejoining Lee until July 2.