On April 10, 1861, he accepted a commission as major general of the Virginia Militia and was directed by Virginia governor John Letcher to assume command of the defenses around Norfolk and Portsmouth until mid-May. Working with Gwynn at Norfolk was William Mahone, who was the president of the Norfolk and Petersburg Railroad. Working under Gwynn's authority, Mahone (who was still a civilian) helped bluff the Federal troops into abandoning the Gosport 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 to the Federals listening in Portsmouth across the Elizabeth River (and just barely out of sight). The ruse worked, and not a single Confederate soldier was lost as the Union authorities abandoned the area, and retreated to Fort Monroe across Hampton Roads.