After the Battle of Seven Pines, which concluded on June 1, 1862, the Union Army of the Potomac, commanded by Maj. Gen. George B. McClellan, sat passively at the outskirts of the Confederate capital of Richmond. The newly appointed commander of the Confederate Army of Northern Virginia, General Robert E. Lee, devoted most of the month to reorganizing his army and preparing an offensive intended to drive the Union invaders away from the capital. He also sent for reinforcements— Stonewall Jackson arrived on June 25 with four divisions (his own, now commanded by Brig. Gen. Charles S. Winder, and those of Maj. Gen. Richard S. Ewell, Brig. Gen. William H. C. Whiting, and Maj. Gen. D.H. Hill) from the Shenandoah Valley following his successful Valley Campaign.
The Union Army straddled the rain-swollen Chickahominy River. The bulk of the army, four corps, was arrayed in a semicircular line south of the river. The remainder, the V Corps under Brig. Gen. Fitz John Porter, was north of the river near Mechanicsville in an L-shaped line facing north-south behind Beaver Dam Creek and southeast along the Chickahominy. Lee's plan was to cross the Chickahominy with the bulk of his army to attack the Union north flank, leaving only two divisions (under Maj. Gens. Benjamin Huger and John B. Magruder) to hold a line of entrenchments against McClellan's superior strength. This would concentrate about 65,500 troops to oppose 30,000, leaving only 25,000 to protect Richmond and to contain the other 60,000 men of the Union Army. It was a risky plan that required careful execution, but Lee knew that he could not win in a battle of attrition or siege against the Union Army. The Confederate cavalry under Brig. Gen. J.E.B. Stuart had reconnoitered Porter's right flank (as part of a daring, although militarily pointless, circumnavigation of the entire Union Army from June 12 to June 15) and found it vulnerable. McClellan was aware of Jackson's arrival and presence at Ashland Station, but did nothing to reinforce Porter's vulnerable corps north of the river.