After driving off the Army of West Virginia under Maj. Gen. David Hunter after the Battle of Lynchburg on June 18, the Second Corps marched northward through the valley, entering Maryland on July 5 near Sharpsburg. They then turned east towards Frederick, where they arrived on July 7. Two days later, as the Second Corps prepared to march on Washington, Maj. Gen. Lew Wallace, leading a small Union force composed mostly of garrison troops, bolstered by the eleventh-hour addition of two brigades of the VI Corps sent from Richmond under Maj. Gen. James B. Ricketts, attempted to resist the Confederate advance at the Battle of Monocacy.