When Virginians voted overwhelmingly to secede from the Union on May 23, 1861, the inhabitants of Alexandria — the ones who had not yet fled, leaving it a virtual ghost town — knew that life soon would change.

It changed quickly.

At dawn the next morning, thousands of federal troops poured in from Washington to seize the once-tranquil city, perched on the banks of the Potomac at a literal crossroads between North and South. They came by steamboat down the river. They marched across the Aqueduct (where the Key Bridge now stands) and Long Bridge (now the 14th Street Bridge), working their way south toward Alexandria.

One of the Union officers invading that morning, Col. Elmer Ellsworth, rushed to the top of the Marshall House hotel to remove the giant Confederate flag waving from its roof.

As he descended the stairs, flag in hand, Ellsworth encountered the hotel’s proprietor, James Jackson, a loyal Southerner who had vowed the flag would come down only over his dead body. Jackson killed Ellsworth with a shotgun blast, only to be shot dead moments later by one of Ellsworth’s men, making good on his grim promise.

“News of their fates rocketed throughout the North and the South, and they were seen as exemplars of boldness and bravery in war,” author Charles P. Poland Jr. wrote in “The Glories of War: Small Battles and Early Heroes of 1861.” “They became a rallying point, the martyred sacrifices of war. Their fate was a prelude of things to come.”

The incident put the city in the national spotlight.

“This is a sad day for Alexandria, and whatever may be the issue of this contest, this unprecedented move upon the part of a Republican President will ever linger in the minds of citizens while memory lasts,” Henry B. Whittington, a clerk for a local mercantile business and a Southern sympathizer, wrote in his diary that day. “The usurpations of power indicated by this movement causes the hearts of freemen to shrink with dread from the contemplation of the future of our beloved country.”

Before the war, Alexandria was a quaint and quiet town marked by brick sidewalks, dignified church steeples and stately Georgian residences. In the wooden pews at Christ Church off N. Washington Street, both George Washington and Robert E. Lee had worshiped.

The city had excellent schools and a respectable newspaper, the Alexandria Gazette, edited by Edgar Snowden. The rail lines coming into the city and its spot on the Potomac River made Alexandria a bustling commercial artery, as well as one of the main slave-trading centers in the upper South, as evidenced by the bleak slave pens that stood along Duke Street.

Elsewhere in the city, the Mount Vernon Cotton Manufacturing Co. hummed on Washington Street. The Pioneer Flour Mill joined other local factories and foundries, even a brewery.

“Alexandria was a mid-size city of its day, a prosperous, river port city,” said James Barber, an historian at the National Portrait Gallery and author of “Alexandria in the Civil War.”

The war brought swift transformation.

“The city quickly lost its placid colonial character and became an active federal supply depot, convalescent center and campground,” wrote George Kundahl in his book “Alexandria Goes to War.” “A labyrinth of wharves, quartermaster storehouses, commissaries, marshalling yards, and railroad shops blanketed the area. Churches, public buildings and abandoned mansions were converted into hospitals, prisons and headquarters.”

Many Alexandrians had fled before the conflict began. Those who remained found themselves living under martial law, virtual captives in a city that was now surrounded by a smattering of Union forts.

Mail service came to a halt. Citizens had to have a pass to leave. Those who wanted to run a business had to obtain a proper license, which meant taking an oath of allegiance to the federal government. Churches that agreed to say a prayer for the president of the United States during their services were allowed to continue unimpeded; those that refused often were seized and put to use as hospitals. The Alexandrian men away at war, most of them part of the Confederacy’s 17th Virginia Infantry, could not return home on furloughs for the duration of the war.

“Alexandria is filled with ruined people; they walk as strangers through their ancient streets, and their property is no longer theirs to possess,” George Alfred Townsend, a correspondent for the New York Herald, wrote in 1863, adding that it “has become essentially a military city. Its streets, its docks, its warehouses, its dwellings, and its suburbs have been absorbed to the thousand uses of war.”

Among those uses were “the appetites and needs of these soldiers,” said Barber, the Smithsonian historian. “All of a sudden you see oyster houses and saloons. Houses of ill repute suddenly begin turning up.”

As the war wound down, Alexandria had begun to regain its footing. Its population ballooned to nearly 17,000 residents, though many of its new inhabitants were Northerners and free blacks.

The headaches and heartaches of its four-year occupation came with at least one silver lining: Alexandria never saw a day of combat. The city remained largely intact, as if preserved in amber.

“It was ironically fortunate in many ways,” Barber said. “Union occupation had a lot to do with preserving [Alexandria]. . . . It remained the quaint, 18th-century early Federal period town that is still there.”

Despite the chain stores, traffic lights and other reminders of modern life, the soul and the structure of the old town remain.

At the corner of Pitt and King streets, the Hotel Monaco stands on the site of the Marshall House hotel. A plaque honors James Jackson as “the first martyr to the cause of Southern independence.”

Outside Christ Church, the remains of 34 Confederate soldiers, prisoners of war who died during the federal occupation, lie in a communal grave. Union troops who perished mostly from disease lie less than a mile away at Alexandria National Cemetery. And off Washington Street sits the site of the Freedman’s Cemetery, the final resting place of many former slaves who came from across the South during the war, seeking refuge.

Their graves serve as a reminder of Alexandria’s role as a unique site in the Civil War — a place where Northerners and Southerners coexisted in relative peace; a place that evolved and adapted as the nation around it changed; a place where, even today, the past remains on display, in nearly every churchyard and down nearly every brick-lined street spared by occupation.