Once Virginia seceded from the Union, Confederate troops occupied the Federal arsenal at Harper's Ferry. Federal troops responded immediately and forced the Confederate troops out of what became the state of West Virginia.
As soon as Virginia formally seceded, Confederate troops under the command of General Beauregard seized the federal arsenal at Harper's Ferry. Before they could arrive Federal troops had attempted to burn it down, but much of the equipment was salvaged. Confederate troops sent the equipment to Richmond, where it was later used to produce arms.
The seizure of Harper's Ferry forced the Union to respond immediately. The seizure of Harper's Ferry cut the B&O railroad that ran from the North of Washington to the west, thus cutting Washington off from the West. In addition much of the population of Western Virginia were more pro union then their Southern brethren. Thus if a successful Union presence could be established in the Western part of the state, it was hoped it would rejoin the Union.
General's McClellan, Cox and Rosecrans organized the militia raised by Ohio and Indiana, and led them into battle in Western Virginia. Their first goal was Grafton, a rail junction held by Confederate troops. Confederate troops withdrew from Grafton to a Philipi, about 15 miles to the south. Union troops followed them and in a quick battle at Philipi, forced the Confederates to flee further south to Beverly. Confederate troops were reinforced at Beverly, but Union troops launched a flanking attack that forced the Confederate troops to flee. In a final battle at Corrack Ford the Confederate General, Garnett became the first general to fall in battle.
In a later engagement General Lee attempted to dislodge Federal troops but to no avail, the Union was in firm control of Western Virginia, which soon declared its independence from the rest of Virginia, and became the separate state of West Virginia.