Virginia Democrats Tom Perriello and Ralph Northam are battling in a very close contest for the party’s gubernatorial primary, with divisions reemerging from last year’s Democratic presidential race, according to a new Washington Post-Schar School poll.

Democratic likely voters say Perriello’s endorsements by Sens. Bernie Sanders (I-Vt.) and Elizabeth Warren (D-Mass.), icons of the national progressive movement, carry at least as much weight as Northam’s support from Gov. Terry McAuliffe and nearly all other Virginia Democrats in Congress and the state legislature.

With less than one month before the June 13 primary, 40 percent of likely Democratic voters support Perriello, while 38 percent support Northam, a difference that is well within the survey’s range of sampling error. Perriello is a former congressman, and Northam is the state’s lieutenant governor.

More than 2 in 10 Democratic voters are undecided or have no current preference, a sign of fluidity leading into the final weeks before the June 13 primary, according to the poll co-sponsored by The Post and George Mason University’s Schar School of Policy and Government.

“I like both the guys,” said Shantanu Sharma, 46, of Sterling. “I’m torn between the guy with the establishment backing versus the guy with Bernie Sanders’s backing.”

Among the broader group of Democratic-leaning registered voters, Perriello holds a slight edge over Northam, with 35 percent support to Northam’s 29 percent.

Northam’s supporters are more apt to fit the profile of likely voters, though — a factor that could prove decisive given that fewer than 10 percent of voters have participated in nonpresidential primaries in the past decade.

Age is a clear dividing line in support, with Perriello, 42, leading Northam by 20 percentage points among Democratic-leaning registered voters ages 18 to 39, while Northam, 57, leads by 16 points among those ages 65 and older. The two run more evenly among voters in between.

As one of only two gubernatorial races nationwide this year (the other is in New Jersey, which is less competitive), Virginia has drawn national attention as a proving ground for how Democrats move forward after Hillary Clinton’s defeat in November.

Perriello’s upstart candidacy has attracted national money and national media as he bashes President Trump at every opportunity, while Northam has patiently built support within the state and has campaigned on his ability to work with the Republican-controlled legislature.

[‘Shades of blue:’ Northam, Perriello may clash mostly on style]

Opposition to Trump clearly resonates with Virginia voters, only 36 percent of whom approve of his performance, according to the poll.

Bridget Hewlett, 48, of Richmond, said she has been distraught and disillusioned with politics after watching how Trump’s administration is playing out.

“I am not that type of Democrat who is hateful. I want him to succeed,” she said. “But he is getting on my nerves, and he is acting too childish. I want a governor who will come in and help the country calm down. I want the country to feel better again. I don’t feel happy.”

Hewlett said she is leaning toward Perriello but hasn’t made up her mind.

Perriello leads by 18 points among Democratic-leaning registered voters who wanted Sanders to win the party’s presidential nomination last year, while Clinton voters split 35 percent for Northam and 34 percent for Perriello.

Judging from last year’s outcome, a Sanders strategy would seem risky in Virginia. Clinton beat Sanders by nearly 30 percentage points in the state’s primary, though voters then were also split along generational lines. Exit polling showed Sanders won nearly 7 in 10 voters under age 30, while Clinton won clear majorities of older voters.

But the poll suggests that Perriello’s Sanders-like approach is finding traction. A 57 percent majority of Democratic likely voters say the Sanders and Warren endorsements make them more inclined to back Perriello. That’s slightly higher than the 50 percent who say the support from McAuliffe and other Virginia Democratic officials makes them more likely to back Northam.

That might suggest a shift in the state party.

“In the past, the Democratic Party of Virginia has always proudly bucked against the more progressive trends on the national party side,” said Mark Rozell, dean of the Schar School. “They’ve always had their success when they projected a more moderate image than the national party. I think things have flipped in some respects. We’re seeing a much more progressive wing of the Democratic Party active in Virginia.”

Lucas Atkins, a 19-year-old college student from Roanoke, said he was drawn to Perriello after reading about his plans to increase taxes on the wealthy to expand social programs and learning he had the endorsements of Sanders and Warren.

“That means a lot to me personally because Bernie and Elizabeth Warren aren’t the average Democrat. They are not the same old centrist Democrat,” said Atkins, who said the election of Trump should send a signal for Democrats to embrace the party’s progressive wing. “I’d like to be optimistic and say some people might have learned the lesson that centrist establishment Democratic policies are not necessarily what the American people want.”

Northam and Perriello agree on most major issues and are seen by voters to possess similar attributes. But Perriello has a slight edge in the perception that he could stand up to Trump (38 percent to 30 percent), while Northam has a similar edge in perception that he could work with state Republicans (38 percent to 31 percent). Still, those results are within the poll’s range of sampling error.

There are a couple of key regional differences. Perriello enjoys a massive advantage in the southwest part of the state, where 58 percent of Democratic-leaning registered voters say they support him compared with 20 percent for Northam. Perriello is from Charlottesville and represented the rural 5th District during his single term in Congress.

Northam, who represented Norfolk in the state Senate, holds a smaller edge in the Hampton Roads region, with 40 percent support compared with 28 percent for Perriello.

Between his career in the legislature and heavy TV advertising in Hampton Roads, Northam is a far more familiar figure in that part of the state. “I haven’t had much knowledge of Mr. Perriello, no advertisements, nothing that would make me kind of think maybe I would prefer him,” said Sandra Wilson, 58, of Norfolk, who said she supports Northam.

The two are running virtually even in Northern Virginia, with 28 percent favoring Perriello and 26 percent for Northam. But more than one-third of those voters remain undecided, making the vote-rich area a major opportunity in the final weeks before the primary.

One part of the national story line that doesn’t hold up: Perriello has been claiming the progressive mantle, but registered voters who identify as “very liberal” are about equally split between the two.

Similarly, Northam has been portrayed as the more conservative of the two, but Perriello has a statistically insignificant lead among moderate and conservative Democrats, 35 percent to 27 percent.

The two are vying to take on one of the three Republicans running for that party’s nomination in the primary. Those candidates are former Republican National Committee chairman Ed Gillespie, state Sen. Frank W. Wagner (Virginia Beach) and Prince William County supervisor Corey Stewart. The poll found Gillespie with a commanding lead in that primary battle.

[Post-Schar poll finds Ed Gillespie with big lead for GOP nomination]

The Post-Schar School poll was conducted May 9 to 14 among a random sample of 1,602 Virginia adults reached on cellular and ­landline phones. The margin of sampling error for individual percentage results is plus or minus 4.5 points among the sample of 654 Democratic-leaning registered voters and six points among the sample of 351 likely primary voters. The range of sampling error for the difference between candidates’ support is 10 points among likely voters.

Emily Guskin, Fenit Nirappil and Laura Vozzella contributed to this report.