Hunter's retreat left the Shenandoah Valley virtually undefended, and Early moved swiftly north, reaching Winchester by July 2. General Sigel, commanding a reserve division, withdrew to Maryland Heights at Harpers Ferry, offering little resistance. On July 4, Early confronted Sigel but then determined to turn the position by crossing the Potomac and moving over South Mountain to Frederick, Maryland. On July 9, Early defeated a hastily organized Union force under Maj. Gen. Lew Wallace at the Monocacy River. Wallace retreated toward Baltimore, leaving open the road to Washington, but his defeat had bought valuable time.
On the afternoon of July 11, Early's command, numbering no more than 12,000 infantry, demonstrated before the Washington fortifications, which were weakly manned by garrison troops. Veteran reinforcements (VI and XIX Corps), diverted from Grant's army to meet the threat on the capital, began arriving at mid- day, and by July 12, fully manned the Washington entrenchments. After a brief demonstration at Fort Stevens, Early called off an attack on the capital. The Confederate army withdrew that night, recrossed the Potomac River at White's Ford and reentered the Valley by Snickers Gap. Maj. Gen. Horatio Wright, commanding the pursuing Union army, attempted to bring Early to bay.
On July 18, a Union division crossed the Shenandoah River west of Snickers Gap but was thrown back at the battle of Cool Spring. Union cavalry were turned back at Berry's Ferry, nine miles farther south, the next day. On July 20, Union Brig. Gen. William Averell's mounted command, backed by infantry, moved south from Martinsburg on the Valley Turnpike and attacked the infantry division of Maj. Gen. Stephen D. Ramseur at Ruthersford's Farm near Winchester and routed it. In response to this setback and converging threats, Early withdrew to Fisher's Hill south of Strasburg.
Early's withdrawal convinced Wright that he had accomplished his task of driving off the Confederate invaders. He therefore ordered the VI and XIX Corps to return to Alexandria, where they would board transports to join the Army of the Potomac. Wright left Crook with three small infantry divisions and a cavalry division at Winchester to cover the Valley.
Under a standing directive to prevent Union reinforcements from reaching Grant, Early was quick to take advantage of Wright's departure. He attacked and routed Crook's command at Second Kernstown on July 24, and pressed the retreating Union forces closely. When Crook retreated toward Harpers Ferry, Early sent his cavalry to Chambersburg, Pennsylvania, to exact tribute or burn the city. The citizens refused to comply, and McCausland's cavalry burned the center of the town in retaliation for Hunter's excesses in the Valley.