Maj. Gen. George B. McClellan's Army of the Potomac remained northeast of Richmond for three weeks after the Battle of Seven Pines. The new commander of the Army of Northern Virginia, Gen. Robert E. Lee, took that time to reorganize his defenses of the capital city and receive the reinforcements of Maj. Gen. Thomas J. "Stonewall" Jackson's division from the Shenandoah Valley. After attacking Lee inconclusively at Oak Grove on June 25th, McClellan remained in place, with four of his five army corps south of the rain-swollen Chickahominy River. Lee took note of the remaining Union Fifth Corps under Maj. Gen. Fitz John Porter in positions north of the river behind Beaver Dam Creek near Mechanicsville. On the morning of June 26th, Lee took the initiative and began his offensive against McClellan’s army by attacking Porter's isolated men. Brig. Gen. A.P. Hill threw his division, reinforced by Maj. Gen. D.H. Hill’s division, into a series of assaults against the Fifth Corps right flank. Maj. Gen. James Longstreet's division attacked Porter's left. Confederate attacks gained little ground and were driven back with heavy casualties. Jackson’s men from the valley, behind schedule but moving into position from the northwest, forced Porter to withdraw the next morning to a position behind Boatswain Swamp just beyond Gaines’ Mill. The action at Beaver Dam Creek was the second of the Seven Days battles that would end McClellan's Peninsula Campaign.