As Union commander George McClellan moved the Army of the Potomac up the Peninsula in early 1862, the Union army still had a nearly 2-1 advantage in manpower, so Army of Northern Virginia commander Joseph E. Johnston continued to gradually pull his troops back to a line of defense near Richmond as McClellan advanced. In conjunction, the Union Navy began moving its operations further up the James River, until it could get within seven miles of the Confederate capital before being opposed by a Southern fort.
McClellan continued to attempt to turn Johnston's flank, until the two armies were facing each other along the Chickahominy River. At this point, the Union army was close enough to Richmond that they could see the city's church steeples, but they would come no closer. By the end of May, Stonewall Jackson had startlingly defeated three separate Northern armies in the Valley, inducing Lincoln to hold back the I Corps from McClellan. When McClellan was forced to extend his line north to link up with troops that he expected to be sent overland to him, Johnston learned that McClellan was moving along the Chickahominy River.
It was at this point that Johnston got uncharacteristically aggressive. Johnston had run out of breathing space for his army, and he believed McClellan was seeking to link up with McDowell's forces. Moreover, about a third of McClellan's army was south of the river, while the other parts of the army were still north of it, offering Johnston an enticing target. After a quick deluge turned the river into a rushing torrent that would make it impossible for the Union army to link back up or aid each other, Johnston drew up a very complex plan of attack for different wings of his army and struck at the Army of the Potomac at the Battle of Seven Pines on May 31, 1862.