William Mahone began aiding the Confederacy while still a civilian through the use of his Norfolk and Petersburg Railroad, when he bluffed the Federal troops into abandoning the shipyard in Portsmouth by running a single passenger train into Norfolk with great noise and whistle-blowing, then much more quietly, sending it back west, and then returning the same train again, creating the illusion of large numbers of arriving troops. The ruse worked, and not a single Confederate soldier was lost as the Union authorities abandoned the area. After this, Mahone accepted a commission as Lieutenant Colonel and later Colonel of the 6th Virginia Volunteer Infantry Regiment in the Confederate Army. He commanded the Confederate's Norfolk district until its evacuation. He was promoted to Brigadier General in November 1861.  He aided in the construction of the defenses of Richmond on the James River around Drewry's Bluff and led his brigade at the Battle of Seven Pines, and the Battle of Malvern Hill. He also fought at Second Bull Run, Fredericksburg, Chancellorsville, Gettysburg, the Wilderness, and Spotsylvania Court House.