During the Civil War the Baltimore and Ohio Railroad made the present-day eastern panhandle a constant battleground. Both the Union and Confederate armies occupied Harpers Ferry, Martinsburg, and Romney on numerous occasions. Meanwhile, the North controlled most areas west of the Alleghenies through key victories at Rich Mountain, Carnifex Ferry and Droop Mountain.
Beyond the strategic importance, the Union's military control of western Virginia protected the political leaders who had gathered in Wheeling to break from the pro-Confederate government of Virginia. These leaders had grown increasingly frustrated with Virgina for its failure to fund roads, railroads and other improvements in the western part of the state. They used Virginia's secession from the Union as an opportunity to break away and form a separate government.
In 1861, leaders from northwestern Virginia established a new Virginia state government that remained loyal to the Union. This government then carved out territory to create a new Union state. On June 20, 1863, West Virginia became the 35th state - the only permanent change in territory due to the Civil War.
It is hard to exaggerate the importance of the Civil War to West Virginia. The outbreak of fighting shattered the sectional peace between eastern and western Virginia. Union forces remained in control of north western Virginia from the summer of 1861 until the end of the war, giving statehood advocates a safe place to work. All of West Virginia, except the Northern Panhandle, was threatened by Confederate guerrillas and raiders. The Confederates remained in control of the Greenbrier Valley until after the creation of the new state in 1863. Loyalties were particular divided in this area, as Virginia Confederates lost their homes to the new state of West Virginia, while those who supported the Union welcomed statehood.
Source: Williams, John Alexander. West Virginia: A History for Beginners. Martinsburg, WV: Appalachian Editions, 1997.