General Robert E. Lee ordered his Confederate divisions of the Army of Northern Virginia, under the field command of Major Generals Benjamin Huger, James Longstreet, and A.P. Hill, to converge upon Union Major General George B. McClellan's retreating Army of the Potomac in transit in the vicinity of Glendale (or Frayser's Farm), attempting to catch it in the flank and destroy it in detail. The Army of the Potomac was moving out of the White Oak Swamp on a retreat from the Chickahominy River to the James River following the perceived defeat at the Battle of Gaines' Mill; as the Union Army approached the Glendale crossroad, it was forced to turn southward with its right flank exposed to the west. Lee's goal was to thrust a multi-pronged attack of his divisions into the Army of the Potomac near the Glendale crossroad, where a vanguard of Union defenders was caught largely unaware.