After victories at Fredericksburg and Chancellorsville, Virginia, early in May 1863, Confederate General Robert E. Lee carried the war through Maryland, across the Mason and Dixon Line, and into Pennsylvania. His infantry marched north through the Shenandoah Valley and western Maryland while his cavalry, led by General J.E.B. Stuart, harassed Union supply lines to the east. Union General Joseph Hooker, replaced on June 28 by General George G. Meade, led the Army of the Potomac from the Washington defenses in pursuit. The Federals collided with Lee's Army of Northern Virginia at Gettysburg, Pennsylvania, on July 1, beginning a battle neither side had intended to fight there. Three days later, the defeated Confederates began retreating through Maryland, retracing their steps to the Potomac River and crossing into Virginia on July 14.