When the Civil War began in 1861, Magruder left the Union Army to accept a commission in the Confederacy. As commander of the Army of the Peninsula, he fortified the Virginia Peninsula and won the Battle of Big Bethel. In the Peninsula Campaign, he stalled McClellan's Army of the Potomac outside Yorktown, allowing Maj. Gen. Joseph E. Johnston to arrive with reinforcements, organize a retreat, and defend the Confederate capital, Richmond. Magruder was criticized for his leadership in battles at Savage's Station and Malvern Hill during the Seven Days Battles. He spent the remainder of the war administering the District of Texas, New Mexico, and Arizona and the Department of Arkansas; in his tenure, Magruder lifted the naval blockade over Galveston and recaptured the city in 1863.