A week after Martinsburg delegates voted against secession, Confederate troops marched through Martinsburg on their way to Harpers Ferry in order to capture the armory there for the South. Residents of Martinsburg protested against their town's occupation by Confederate forces and this led to Colonel Thomas J. Jackson's decision to send reinforcements in hopes of demonstrating Southern resolve. Although Confederate troops took over the city, Martinsburg residents remained Unionist. This pro-Union sentiment only grew stronger when Jackson sent more troops to Martinsburg and ordered the destruction of area railroads and bridges to sow the Union army's response.
Two months later, Union General Robert Patterson arrived in the area. On July 3, 1861, these Union troops secured control of the city and Patterson used the courthouse as his headquarters. Although majority of Martinsburg hoped to stay neutral or supported the Union, the city was home to Confederate supporters such as the soon-to-be-infamous Belle Boyd. On July 4th, a Union soldier reportedly swore at the mother of Belle Boyd in the midst of an argument. In response, Belle Boyd shot the man and this action began her career as an outlaw and spy for the Confederacy.
The city changed hands from Confederate to Union and back many times in 1861 and 1862. Following the battle of Antietam, much of the city served as a makeshift Union hospital. The Confederacy gained control of the city several times in 1863 and 1864 and it was not until the final year of the war that this pro-Union city in what became the Unionist state of West Virginia remained under the control of local residents and Unionist forces.