Democrats accelerated Virginia’s historic partisan shift from red to blue on Tuesday, winning control of the State Senate and edging closer to flipping the House of Delegates as votes continued to be counted.
In an election where passions about President Trump and the impeachment inquiry drove voters on both sides, a revolt against the president in Virginia’s rapidly growing suburbs helped remake the state’s political map. Now, under Gov. Ralph Northam, who survived scandal earlier this year, Democrats are positioned to advance a set of sweeping liberal priorities in the Senate and possibly in the House.
Going into Tuesday, Republicans held a 20 to 19 advantage in the State Senate, with one vacancy. Democrats picked up at least two seats, including an upset in a suburban Richmond district by Ghazala Hashmi, who will be the first Muslim woman in the Senate. A former college literature professor, Ms. Hashmi was brought to the country from India as a child. Running her first campaign, she described experiencing a personal crisis after Mr. Trump ordered a ban on immigration from Muslim-majority countries.
“I didn’t know if I actually had a home in this country,” she said in an interview last week. “My anxiety was caused by wondering if other people would speak up and support the assault we were seeing on civil liberties.” She decided to speak up and represent herself.
Pre-election polling showed the top issues were all ones that favored Democrats: raising the minimum wage to $15, spending more on roads and, after a mass shooting in Virginia Beach this year, expanding background checks and banning assault weapons.
After Mr. Northam called a special session of the legislature to respond to gun violence over the summer, and the Republican majorities adjourned it after just 90 minutes, Democrats thought they had won a moral victory to use against opponents in the fall. Republicans denounced the session as a political stunt.
The balance of power in both chambers turned on just a handful of competitive districts, all in suburban regions outside Washington, Richmond and in Hampton Roads.
Swing-district Republicans backpedaled away from Mr. Trump and the party, a brand that had proved toxic in last year’s midterms with the increasingly diverse electorate in suburbia. Some Republicans campaigned more like Democrats, boasting of support for Medicaid expansion that the party long fought in Richmond, for L.G.B.T. rights and even for gun safety measures.
With so much at stake — a referendum on the president, the partisan balance of both houses, political momentum going into a presidential election — money cascaded into the normally low-interest legislative races.
Republicans came into Election Day with a 51 to 48 majority in the House of Delegates and its narrow edge in the Senate. Each chamber had one vacancy.
In 2017, Republicans clung to power in the House by a single seat that was decided by a random drawing after the election in that district resulted in a dead tie.
State senators, who serve four-year terms, had not faced voters since 2015, before Mr. Trump’s election. Many Republican senators who were considered most vulnerable occupied districts carried by Mr. Northam in 2017 and by three Democrats who flipped congressional races in 2018.
A scandal that engulfed the governor and other top Democrats in the state early in the year seemed to have faded from voters’ concerns, as it had from headlines. After a racist photo on Mr. Northam’s medical school yearbook page surfaced in February, he offered to resign. But he quickly reversed himself, and polls now show many more voters approve of his performance than disapprove.
Another factor aiding Democrats was a court-ordered remapping of districts in southeast Virginia. In June, the United States Supreme Court upheld a lower court decision striking down earlier maps as racially gerrymandered. New maps shifted 425,000 voters in 25 districts. They more evenly distributed black voters, which gave Democrats an overall advantage, according to an analysis by the nonpartisan Virginia Public Access Project.
The House seat that was decided by the random drawing two years ago — in favor of David Yancey, a Republican from Newport News — was tilted toward Democrats in the redistricting. Shelly Simonds, who lost the drawing, ran again this year in a rematch and won.
Likewise, Kirk Cox, the Speaker of the House and Virginia’s most powerful Republican, ended up in a new district that shifted significantly leftward, one that Hillary Clinton had carried. His campaign ads skipped partisan rhetoric and portrayed him as a former baseball coach who supports education spending.
More than $1 million flowed to 16 individual candidates, who were seeking part-time jobs that pay less than $20,000 a year.
Races where television ads had been unheard-of echoed with a cacophony of attacks while Virginians tried to tune out politics for a brief respite during the World Series.
Emily’s List, which supports women running for office who back abortion rights, pumped more than $2 million into Democratic races mostly for the House. The former New York mayor Michael R. Bloomberg was the largest outside individual donor. His group Everytown for Gun Safety gave $2.5 million to help Democrats, and Beyond Carbon, his climate change group, donated more than $600,000 to two House candidates in coastal districts.
Republicans’ largest donor was the Republican State Leadership Committee ($3.2 million), a national group that supports state-level races, the value of which became clear after sweeping Republican legislative victories in 2010, which led to Republican-drawn voting maps that have influenced power in the states and in Congress.
This year, the prospect of the 2021 redistricting after the next census was a quiet but powerful issue for both parties.
In recent days, nationally prominent Democrats campaigned alongside statehouse candidates to raise voters’ enthusiasm, including the presidential candidates Joseph R. Biden Jr., Amy Klobuchar and Kamala Harris.
On Saturday, Senator Mark Warner, Democrat of Virginia, sought to inspire volunteer door-knockers by citing what he viewed as Republican outrages in Washington, including Mr. Trump’s abandonment of Kurdish allies in Syria and smears against a decorated Army officer called to testify in the impeachment inquiry.
He suggested Democrats could force congressional Republicans to “grow a backbone” by flipping the Virginia House and Senate.
Republican surrogates were less visible. Mr. Trump skipped campaigning for fellow Republicans in the state, though Vice President Mike Pence held a rally in Virginia Beach.
At a get-out-the-vote gathering on Saturday for the Henrico County Republican Committee, once a Republican stronghold outside Richmond, the headliner was a local talk radio host, John Reid.
“I think Democrats have overreached beyond belief,” Mr. Reid told the party faithful, referring to impeachment proceedings. He predicted Republicans would have a good day on Tuesday. “Donald Trump upsets people — that’s fine,” he said. “It cannot be denied that he’s delivered.”