Former Virginia congressman Tom Perriello speaks at a rally announcing his candidacy for the Democratic nomination for governor of Virginia in Charlottesville on Jan. 5. (Steve Helber/Associated Press)

Just like that, Virginia has a governor’s race worthy of the intense national scrutiny it’s going to get.

Former congressman Tom Perriello rattled the Democratic establishment Thursday by unexpectedly declaring that he would seek the party’s nomination for governor. That not only upset the plan for the earnest, low-key Lt. Gov. Ralph Northam to unify the party as its anointed candidate, it also plunged Virginia into an intriguing story line that echoes the recent presidential contest.

Like a Netflix reimagining of November’s election, Virginia now features, on the Democratic side, a well-funded but unexciting establishment candidate (Northam) challenged from the left by a surprising upstart (Perriello).

On the Republican side, the well-connected Ed Gillespie, a longtime strategist for national candidates and adviser to President George W. Bush, is trying hard to seem inevitable. But he faces an X-factor challenge for the nomination from Corey A. Stewart, the Prince William County supervisor who led Donald Trump’s campaign in the state until he got too rogue even for the unconventional Trump operation.

And state Sen. Frank W. Wagner (R-Virginia Beach) is a dark-horse candidate who has strong support in the populous Hampton Roads region. Both parties will hold June primaries.

“Perriello is definitely spitting in the face of Virginia’s Democratic political leadership, because they surely did not want this,” said University of Virginia political scientist Geoffrey Skelley. “It’s going to be really fascinating.”

As one of only two states to feature gubernatorial elections in 2017, Virginia’s contest has been shaping up as a proxy for the identity crisis both major parties face after last year’s stunning presidential outcome. The national parties are expected to pour money and attention into Virginia.

Democrats who wonder if — just maybe — the anti-establishment Bernie Sanders could have beaten Trump may see an opportunity for a do-over in Perriello. And Republicans uneasy with the direction Trump has taken their party might look for solace with the steady Gillespie.

Until now, most of the hand-wringing in Virginia has been on the Republican side, which looked to have a nasty internal fight on its hands between the mainstream and the Trump insurgency.

Gillespie, who has led in fundraising and endorsements, must figure out how to run as a Republican in the Trump era. He earned goodwill across the party’s establishment and tea party wings by nearly unseating Sen. Mark R. Warner (D) in 2014. But after keeping his distance from Trump last year, Gillespie could have a harder time with some of the incoming president’s supporters.

But now there’s a little glee that the Democrats are facing the same kind of reckoning.

“This is really the first battle in a war that will play out over the next few years over who will control the very heart and soul of the Democratic Party,” said Phil Cox, a national Republican strategist who managed the campaign of former Virginia governor Robert F. McDonnell and is a senior adviser to Gillespie. “For Republicans sitting on the sidelines watching, it’s going to be highly entertaining.”

But also, potentially, threatening.

While Republicans control the Virginia legislature, Democrats own the executive branch and the state’s two U.S. Senate seats. Republicans have been hoping 2017 is their chance to take the governor’s mansion and consolidate power. Perriello’s entry shakes up their calculations.

Perriello, 42, grew up in Charlottesville and held the sprawling 5th Congressional District seat for one term before losing in the 2010 general election.

He went on to work for the Center for American Progress, a liberal think tank, before joining President Obama’s State Department in 2014. He later served as a special envoy for the Great Lakes Region of Africa until stepping down in December.

An early and prominent Obama ally during his time in Congress, Perriello blindsided state Democrats on Wednesday night with a round of phone calls notifying them that he was planning to run for governor. He said Thursday that he had been prohibited by the Hatch Act from pursuing a campaign while he was a federal employee. It was only in the past 10 days, he said, that he and his family decided to go for it and he began assembling a staff.

Perriello formally announced Thursday morning with a slick campaign video that hit on populist themes and with an appearance in a coffee shop near the North Carolina border — a region of the state hit hard by the loss of manufacturing jobs.

“We started in Danville today because it used to be the heart of the Virginia economy but like too many VA communities, has been left behind,” Perriello tweeted to his 16,400 Twitter followers. (Northam has fewer than 6,300 followers and uses Twitter far less.)

The name of the Danville shop — Brewed Awakening — jibed with the jolt Perriello was delivering to Democratic leaders, who for more than a year had been confident that Northam would have no opponent for the June 13 primary.

At midday, Perriello spoke to a hastily assembled crowd of 80 or more in Charlottesville, pulled together mainly through social media. His mother, Linda, introduced him — the first step in what will have to be a whirlwind introduction of the candidate to voters statewide.

Linda Perriello cast her youngest son as “an enormous risk-
taker. He used to jump off of eight-foot brick walls in a Spider-Man costume.” As he grew older and came under the influence of his father and sports and the Catholic Church, he “developed a strong moral core,” she said. “And let me tell you, being a risk-taker with a strong moral core is very powerful.”

Here is where Perriello deviates, a bit, from the replay-of-2016 script: While he touts himself as a progressive, some of his positions during his two years in Congress, on topics such as abortion and guns, were more conservative than Northam’s.

“Certainly as a congressperson who represented part of rural Virginia, he had a position that was not fully in line with urban Democrats,” former Virginia Commonwealth University political scientist Bob Holsworth said.

Perriello himself rejects any comparison to Sanders.

“I’m most associated with Barack Obama,” Perriello said after his event in Thursday, adding — when asked — that he would welcome Obama’s help on the campaign trail.

That, of course, is another juicy story line in the race: Northam is the successor chosen by current Gov. Terry McAuliffe (D), a close confidant of Bill and Hillary Clinton and wielder of their election money and machinery.

Perriello is admired by Obama, who campaigned for him in the 2010 congressional race and assuaged his loss with a diplomatic posting.

Those alliances raise the specter of the old Clinton-Obama rivalry that permeated national Democratic politics a decade ago.

Clinton still has a lot of support among state Democratic leaders, who were proud of Virginia being the only Southern state to tilt her way in the election. And Northam is a standard-bearer who lacks any of the Clinton baggage.

He is a Virginia Military Institute graduate, Gulf War veteran and pediatric neurologist who hunts, fishes­ and speaks with the folksy drawl of an Eastern Shore native. Supporters say his biography and collegial manner could play well across an increasingly polarized state, where Democrats have dominated Northern Virginia and other urban centers but have little following elsewhere.

For now, though, Virginia Democrats are just beginning to absorb this unexpected spectacle.

At the Charlottesville announcement, Jon Chasen, a 40-year-old financial adviser and member of the Albemarle County Democratic steering committee, said he was intrigued by the new development.

“I’m a fan of Northam,” he said. “He’s a great Virginia gentleman, but he may be just too boring for the electorate. Tom is young and a little different. I don’t know if you can run on that or not. . . . But I’m open to both at this stage.”

Last year’s election clearly demonstrated the public’s appetite for something outside the mainstream, Chasen said. But the first few months of the Trump administration will show how that translates into reality and what it means for politics. “We’ll see if people are comfortable with that,” he said, “or maybe they’ll move right back to establishment candidates on both sides of the aisle.”