Following their defeat at the Battle of Gettysburg, Lee's Confederate Army of Northern Virginia retreated across the Potomac River at Williamsport, Maryland, and withdrew into the Shenandoah Valley. Maj. Gen. George G. Meade's Army of the Potomac, in pursuit of Lee's army, decided to try to flank the Confederate army by crossing the river east of the Blue Ridge Mountains at Harpers Ferry and Berlin, Maryland, into the Loudoun Valley and then forcing a passage across the Blue Ridge in Lee's rear. To this end, on July 23, Meade ordered the III Corps, under Maj. Gen. William H. French, to cut off the retreating Confederate columns at Front Royal, Virginia, by forcing passage through Manassas Gap.