Supporters of Democrat Ralph Northam erupt in joy as it is announced he won the governorship over Republican Ed Gillespie, at a rally at George Mason University in Fairfax, Va., on Tuesday. (Michael Robinson Chavez/The Washington Post)

The sweeping gains won by Democrats in Tuesday’s elections complete Virginia’s transformation into the only blue state of the old Confederacy. Where the Harry Byrd machine once conspired to keep black students out of white schools, now a transgender delegate will take her seat alongside Latino women, a socialist and only the second African American elected statewide since Reconstruction.

The old edifices are falling faster than the state’s Confederate statues — but those are under scrutiny in Richmond these days, too. Even Virginia’s most politically powerful corporation — Dominion Energy — is being rattled: Some 14 of the newly elected Democrats have pledged to refuse contributions and challenge the priorities of a company that’s known as the state’s shadow government.

Change has been coming to the increasingly diverse state for years, but the evolution was turbocharged by the provocative influence of Donald Trump.

The president’s victory last fall and subsequent knife-twisting tweets inspired a surge of Democratic candidates to run for office and pushed many voters to the polls.

How Northam gained in a more polarized Virginia

“This election, more than anything else, was a Trump-effect election,” said Stephen Farnsworth, a political scientist at the University of Mary Washington. Democrat Ralph Northam won the governor’s race over Republican Ed Gillespie by a comfortable nine-point margin, but Farnsworth said the outcome could have been much tighter if not for highly motivated anti-Trump voters.

“So many people in this election told pollsters they were voting against Trump more than for or against the actual candidates for governor,” Farnsworth said.

That was particularly evident in the state’s suburban regions, where Northam racked up wide margins and Democratic challengers unseated Republican incumbents in the House of Delegates.

The sentiment turned up in voices across the state. In Fairfax Station, where Pam Rodriguez, 44, showed up in the chilly evening rain to vote for Northam partly because she is “not a fan of Trump . . . I loved the commercial where Northam called him a narcissistic maniac,” she said.

It was in eastern Henrico County outside Richmond, where a few days before the election Nick Hall was all set to vote for the Democrat for governor even though he wasn’t sure of his name. Hall just wanted to strike back at the party of Trump. “Trump is an idiot,” he said.

In exit polling, more than a third of voters said they came out to the polls to express opposition to Trump. Half that many said they voted to support Trump.

An especially striking aspect of that anti-Trump fervor was that most of those new candidates he inspired were women. Of the 15 Democrats who were on track to flip Republican seats in the House of Delegates, 11 were women.

The latest stories and details on the 2017 Virginia general election and race for governor.

All of the delegates they will replace are men.

There were only 17 women among the 100 members of the House of Delegates in its most recent session. Tuesday’s gains will bring that total to 28 — its highest level in history.

“Make no mistake about it: 2017 is the year of the woman in Virginia politics,” Farnsworth said.

The election stunned both sides. Republicans had enjoyed a seemingly untouchable 66-34 majority in the House of Delegates and even designated a new speaker of the House for next year — Del. M. Kirkland Cox (Colonial Heights) — who has been assembling a staff and preparing his office.

Northam drew ire from fellow Democrats just a few weeks ago, when he told Cox during a moment of bonhomie that he looked forward to working with him as speaker.

That role is in question now as Democrats appear headed for at least a 50-50 split in the House, pending the resolution of a handful of close races.

Some Republicans saw Tuesday’s result as a tsunami that couldn’t have been avoided — thanks, of course, to Trump.

“I’m for 90 percent of what President Trump wants to do, but I’m against 90 percent of what comes out of his Twitter,” said former Republican delegate Dave Albo, who stepped down this year and on Tuesday saw his seat in Fairfax County go to a Democrat.

The president whipped Democrats into a frenzy, Albo said. “One of the rules of politics,” he said, “is pissed-off people show up.”

He said it’s not accurate to call Virginia more Democratic in the wake of the election. “This is not a purple state. It’s like, dark red and dark blue spots,” Albo said.

The results did, in fact, amplify the state’s divisions. Blue regions got bigger, as more suburbs flipped for Democrats — especially in the outer D.C. suburbs and around Richmond and Hampton Roads. But rural red areas went for Gillespie in great numbers, sometimes even more than for Trump last year.

And the Democratic Party itself, for all its huge gains, is going to have serious issues to resolve.

“We’re not unified in Virginia yet. We just made this momentary historic gain because we were strategically unified,” said Josh Stanfield of the progressive group Activate Virginia, which worked for many of the new Democratic House of Delegates candidates. “That should not imply that the party is not fractured.”

Some of the progressive candidates — such as democratic socialist Lee Carter, 30, who defeated incumbent Del. Jackson H. Miller in Manassas — were not aided by the Democratic Party of Virginia and are nursing grievances, Stanfield said.

What’s more, it was Stanfield’s group that came up with the anti-Dominion pledge signed by so many of the new candidates. Other Democrats, including Northam, have taken large contributions from Dominion, the state’s largest corporate political donor, and favor the controversial natural gas pipeline it is building in rural parts of the state.

The new Democratic wave could lead to chaos. Pipeline protesters disrupted several of Northam’s campaign appearances, and protesters who favor “sanctuary cities” for undocumented immigrants briefly halted Northam’s victory speech Tuesday night.

“One thing that’s for sure: This should not be interpreted as a kumbaya moment, and from now on, there’s some sort of unified Democratic Party,” Stanfield said.

On Wednesday, Northam said he thought Democratic voters had turned out in such force to call for just that — a more unified and cooperative approach to government. He invoked “the Virginia way,” the old idea that the state’s lawmakers govern through civility and cooperation.

It was an anachronistic reference at a time when the state seems to have put on a fresh face.

“I’m not convinced we have that old Virginia way left anymore,” said Quentin Kidd, a political scientist at Christopher Newport University. But there’s something else that might still limit the pace of change.

“A lot of these candidates were novice candidates,” Kidd said. So when they get to Richmond, “there’s going to be a massive learning curve. . . . There is something to be said for institutional inertia.”

Rachel Chason, Jenna Portnoy and Scott Clement contributed to this report.