There was one close race and one not-so close race in the gubernatorial primaries in Virginia on Tuesday, but the margins were the opposite of what most expected: Lt. Gov. Ralph Northam (D) beat former U.S. Rep. Tom Perriello (D) by about a dozen points in the closely-watched Democratic primary. Meanwhile, 2014 Senate nominee and former Republican National Committee Chairman Ed Gillespie (R) just squeaked by Prince William County Board of Supervisors Chairman Corey Stewart (R) in the not-as-closely watched GOP primary.

As the general election period begins, we’re moving the race from Toss-up to Leans Democratic. This is an election that Democrats should be able to nationalize with President Donald Trump in the White House in a state where Trump’s approval is low. Almost all state-level elected Democrats believed that Northam was a better fit for this statewide race than Perriello. That’s both because Northam’s low-key style is more in keeping with the model of previously successful statewide Democrats (as opposed to the more fiery and populist Perriello) and because they believed Northam’s background in state government was a better fit for the job than Perriello’s background, which is in federal government and advocacy. National Republicans strongly preferred Gillespie to Stewart, but Gillespie’s narrow escape must concern them.

The stakes for Democrats are high: Losing would be a bitter disappointment for them as they seek to chip away at the Republicans’ hefty 33-16 majority in overall control of state governorships (there is one independent, Gov. Bill Walker of Alaska). The Democrats start the race with significant advantages, but Republicans have time and opportunity to whittle them down, given enough breaks.

But before we look ahead, let’s look back at the primaries, both of which featured noteworthy results.

The Northam-Perriello battle was a regional one, with Perriello dominating the middle and western parts of the state, a chunk of which he used to represent in Congress, and Northam winning the eastern half, which is far more populated.

Northam won almost every county and independent city in the Urban Crescent, which comprises the state’s three eastern urban areas (Northam’s Hampton Roads home base along with Northern Virginia and Greater Richmond). Northern Virginia in particular seemed like a battlefield throughout the race, but Northam narrowly won the sometimes-bellwethers of Loudoun and Prince William counties and rolled up big, 60%+ vote shares closer to Washington D.C. in densely-populated Arlington and Fairfax counties, as well as the city of Alexandria.

The Washington Post’s endorsement of Northam helped him in the DC area, and he is not the first Democrat to benefit from the liberal editorial page’s blessing. Eight years ago, the Post’s endorsement helped propel state Sen. Creigh Deeds (D) to a surprisingly strong win in the Democratic gubernatorial primary. While it’s hard to know the precise effect of the Post’s support for Northam, it gave him an extra boost in the vote-rich area (Northern Virginia as a whole made up 39% of the primary vote). Indeed, top reporters noted that Perriello’s internal polling found that his support eroded precipitously after the Post endorsement. Northam’s overwhelming support from state elected officials also assuredly helped: Primaries are often powered by disciplined party regulars who take their cues from governors, members of Congress, and state legislators, nearly all of whom backed Northam over Perriello. The insurgent Perriello garnered an impressive amount of free, positive, “earned” media from many national publications, but Northam’s richer coffers allowed him to run more paid media, which ultimately can be more helpful in getting votes.

Pre-election surveys showing that Perriello was leading among black voters were very likely wrong, although without exit polls it’s hard to know what the overall breakdown was. Still, we feel confident saying that Northam won black voters, and not just by a tiny margin: Northam rolled in his home base of Hampton Roads, where a sizable share of the state’s African Americans live, and he also won more than 70% in a number of majority-black localities, including the city of Petersburg (south of Richmond), which is 77% black — the highest concentration of African Americans in any of the commonwealth’s counties or independent cities. Perriello did do very well in his geographic base of Central Virginia, including getting 80%+ in Danville and Martinsville, two small cities that are about half African American, and he also won a number of sparsely-populated counties in “Southside” (South-Central) Virginia with substantial African-American populations. So the black vote does not seem to have been uniform throughout the state, even though Northam did defeat Perriello handily in precincts that were 95%+ plus African American, according to the Virginia Public Access Project.

The Democratic race drew comparisons to the 2016 Democratic presidential contest between Hillary Clinton and Bernie Sanders, but the contest may have been better viewed through a national-state lens — Northam had the backing of almost all Democratic elected officials in Virginia while Perriello had support from Sanders, Sen. Elizabeth Warren (D), and many staffers in former President Barack Obama’s orbit. But in a bid to help further assess the Perriello-Sanders connection, we have put together Map 1, a precinct map comparing Sanders’ performance in the 2016 Democratic presidential primary to Perriello’s showing in the 2017 gubernatorial primary.

Map 1: Perriello’s performance in the 2017 Democratic gubernatorial primary compared to Sanders’ performance in the 2016 Democratic presidential primary, by precinct (showing how much better or worse Perriello did compared to Sanders)

Notes: 2017 results are unofficial. Click to enlarge.

The map shows that, at least at a precinct level, Sanders and Perriello differed a great deal in many parts of the commonwealth. In fact, the correlation between their precinct-level results was just .304, a moderate-to-weak relationship. The two most notable geographical differences between Perriello and Sanders were Perriello’s better performance throughout Central Virginia and Southside, and Perriello’s worse performance in parts of Hampton Roads and the Tidewater. What that suggests is a phenomenon that is an important part of all elections, but particularly primary contests: the “friends and neighbors” effect, i.e. the boost in voting that a politician gets from his or her home base. Perriello represented VA-5 in the U.S. House for one term, and the dark swath of blue that covers the middle of the map — indicating he did more than 30 points better than Sanders in those precincts — covers most of the district. Meanwhile, Northam overwhelmingly won the Eastern Shore and much of Norfolk, which form his home base, thus leaving many parts of that area red on the map. Overall, Northam won Hampton Roads (which doesn’t include the Eastern Shore) by almost exactly the same margin, 40 points, as Clinton did in 2016. Because Perriello performed better than Sanders in all three metropolitan areas and the rest of the state as a whole — Sanders lost by 29 points, Perriello by 12 — there is understandably a lot more blue on the map than red.

Gillespie, who won by a little more than a point, was probably hurt by the candidacy of state Sen. Frank Wagner (R), who ran as a moderate. Wagner ran a distant third, garnering about 14%, but his share of the vote was generally higher in places where Gillespie did well, namely in Hampton Roads, Wagner’s home base. In terms of ideology and temperament, Gillespie found himself as the man in the middle compared to his rivals, squeezed on the left (if there is one in today’s GOP) by Wagner and on the right by Stewart, who ran a campaign of cultural revanchism aimed at defending the Commonwealth’s Confederate war memorials. In the 2016 presidential primary, Marco Rubio probably would have won the state had he not also been squeezed to his left by John Kasich, which gave Donald Trump a path to a small plurality in that important Super Tuesday primary. The same dynamic harmed Gillespie but didn’t prevent him from prevailing.

Importantly, Northern Virginia made up a notably smaller share of the overall GOP primary vote than it did in the 2016 Republican presidential primary. Table 1 presents regional data from Tuesday’s primary and the 2016 presidential edition. The rest of the state outside of the Urban Crescent made up almost exactly the same share as it did in 2016, but because of Northern Virginia’s decrease, that meant many of the most culturally conservative parts of the state outside the major metropolitan areas held increased sway in the Republican primary.

Table 1: Regional voting in Virginia’s Urban Crescent and the rest of the state

Note: 2017 results are unofficial.

The reduction in the Northern Virginia share also corresponds with a theory that many moderate, white-collar voters in the region may have opted to vote in the seemingly more competitive Democratic primary — Virginia is an open primary state with no party registration — perhaps boosting Northam and robbing Gillespie of some potential votes. However, as some analysts suggested on Tuesday night, many of those voters may simply just be Democrats now, likely having voted for Clinton last November and maintaining negative views of President Trump. While some primary voting patterns are not useful for discussing the ensuing general election, this potential shift, which has been happening for a while now in Northern Virginia but really zoomed ahead in 2016, could be very problematic for the GOP in November. One of the reasons Gillespie nearly upset Sen. Mark Warner (D) in Virginia’s 2014 U.S. Senate race was his relative strength in Northern Virginia compared to other recent statewide Republican candidates. If he can’t replicate that feat in 2017, it will be difficult for him to win the general election.

Perhaps we shouldn’t have been surprised by a populist Republican primary jolt in the state that delivered the Tea Party’s highest-profile defeat of any congressional incumbent: Rep. Dave Brat’s triumph over former House Majority Leader Eric Cantor three years ago. But the voting patterns defy easy categorization: for instance, Brat’s VA-7 delivered the establishment-favored Gillespie his second-biggest win among the state’s 11 congressional districts, according to data compiled by J. Miles Coleman for the excellent elections site Decision Desk HQ. The larger vote share from the Richmond area compared to the 2016 presidential primary proved pivotal for Gillespie — it was his best region and he won the state by fewer than 5,000 votes. Hampton Roads saw the largest growth in vote share relative to 2016, surely because of Wagner’s candidacy (“friends and neighbors,” again).

There was some logic, albeit perverse to most, in Stewart’s embrace of Virginia’s Confederate past. As one of us argued in the Washington Post in early May, Stewart’s strategy gave him an opportunity to generate free name ID in a race in which he was outmanned by the better-funded Gillespie campaign, and making enemies on the left probably helped endear him to very conservative primary voters. While Stewart’s rallies in defense of the monuments did not draw many attendees, let’s remember that the ballot box is private while a rally is public. It stands to reason that Stewart’s crusade drew more support than most polls could measure — a dynamic that is somewhat reminiscent of Stewart’s role model, President Trump.

Speaking of polls, accurate ones were few and far between, although primaries are notoriously hard to survey. The only pollsters that seemed to have a handle on the Democratic race were the few showing Northam ahead. Northam’s internals consistently showed him leading by at least high single digits. Public pollsters, such as the Washington Post/Schar School and others, generally indicated a tie or a small lead for Perriello. The Northam campaign’s polling simply did a better job of drilling down on exactly who was likely to vote in a primary. Meanwhile, polls of the GOP race often showed Gillespie with a big lead, although one late poll by a new firm, Change Research, showed Stewart up 42%-41% on Gillespie, which came very close to nailing Gillespie’s eventual one-point victory (Change missed badly on the Democratic race, though, showing Perriello up by 8% when Northam won by 12%, an error of 20%). So, taken in total, the public primary polls were nothing to write home about.

In terms of turnout, both the Democratic and Republican races featured higher-than-expected raw vote totals. Echoing the half-million voters who showed up for New Jersey’s uncompetitive Democratic gubernatorial primary on June 6, more than 540,000 Virginians cast a ballot in the Northam-Perriello race. That mark is a record for a non-presidential statewide primary in Virginia, surpassing the 493,000 or so that voted in the 1977 Democratic primary for governor and the 1996 Republican primary for U.S. Senate. Raw turnout also vastly exceeded the 320,000 votes in the 2009 Democratic primary for governor, the most recent gubernatorial primary. The conventional wisdom was that higher turnout would be good for Perriello because it might mean a greater number of lower-propensity primary voters were showing up, including younger voters who were more inclined to back him. In the end, Northam still won by 12 points despite, or perhaps even because of, that higher turnout. Meanwhile, around 365,000 votes were cast in the GOP primary, the second-most in a Virginia Republican gubernatorial primary (though there have only been four, and just three were actually contested). The 2017 edition fell short of the 400,000 or so who voted in the 1989 GOP gubernatorial primary. But much like the 1989 contest, the 2017 race wound up being very close, with a margin of less than two points in both elections; unlike the 1989 contest, though, the 2017 race wasn’t expected to be this competitive.

All in all, about 60% of the total votes were cast in the Democratic primary while 40% were cast in the Republican primary. It’s not that GOP turnout was low — rather, it’s that Democratic turnout was high. Perhaps this, like some of the special election results around the nation that we’ve been monitoring lately, is another sign of increased Democratic engagement in the Trump era.

Now let’s look ahead to November, where there are a number of factors working in favor of the Democrats, enough that Northam starts as the favorite, though not necessarily an overwhelming one.

A major reason is that Virginia is trending Democratic. Democrats won the governorship in 2013 and reelected Warner in 2014. Both races were closer than polls predicted — and Gillespie only lost to Warner by a point — but Democrats didn’t win all that many big gubernatorial or Senate races in purple states during the latter years of the Obama era. Virginia was among the exceptions, and then in 2016, Hillary Clinton actually slightly improved on Barack Obama’s 2012 presidential margin, carrying Virginia by more than five points. In 2016, the Old Dominion was more Democratic relative to the national presidential result than it had been since World War II, which represented the beginning of the end of the old Democratic “Solid South.”

Democrats grew their support in Virginia despite the baggage of the Obama years, and Gov. Terry McAuliffe (D) broke a three-decade trend of the presidential “out” party winning the Virginia governorship.

The Virginia gubernatorial race, which is one of the first significant statewide races conducted after any presidential election, is sometimes a harbinger of what is to come. The victories of now-Sen. Tim Kaine (D) in the competitive 2005 race and former Gov. Bob McDonnell (R) in a 2009 landslide presaged good performances for their respective parties in the following year’s midterm. McAuliffe’s win did not, but just the presence of a Republican in the White House probably helps the Democrats in this race because of the usual boost the “out-party” typically gets in non-presidential races. That Trump did so poorly in Virginia for a Republican last year, and that Trump’s popularity is deeply underwater both nationally and even more so in Virginia, is a drag on Gillespie’s candidacy.

Fatigue probably has not set in with Democrats in Virginia because Northam is going for just a second consecutive Democratic gubernatorial term and outgoing Gov. McAuliffe’s approval numbers are sound (Virginia is the only state that does not permit one-term incumbents to seek reelection). If Northam wins, it’ll be four wins in five cycles for the Democrats, and seven of the last 10, dating back to Chuck Robb in 1981. Northam, an unassuming candidate who ran a campaign that was less moderate and more liberal than his reputation — particularly on social issues — stylistically still is more in the mold of a Chuck Robb, Mark Warner, or Tim Kaine than Tom Perriello.

Still, Northam has some work to do. Youth turnout can always be a challenge for Democrats, and Perriello — like Bernie Sanders, his prime endorser — was a candidate of the young, as exemplified by both of their impressive college-town performances. Getting good youth turnout is not an absolute necessity for Northam, but it would certainly help. Opposition to Trump will assist the party in papering over wounds from the primary, but the Northam campaign cannot take such unity for granted, particularly because Perriello’s younger backers may be the kinds of voters who skip the general. Perriello did immediately endorse Northam, and the party seems committed to coming back together (a unity rally scheduled for Wednesday was canceled because of the horrifying shooting in Alexandria at the Republican Congressional baseball team’s practice).

Solid African-American turnout is also a Northam priority, and his apparently robust performance with that bloc of voters is helpful. His new running mate might help in that regard, too. Attorney Justin Fairfax (D), an African-American lawyer, won the lieutenant gubernatorial primary after he narrowly lost a 2013 primary for attorney general. There’s some evidence that having a black candidate on the statewide ticket can help with black turnout. Rounding out the Democratic statewide ticket is Attorney General Mark Herring (D), who deferred to Northam in the gubernatorial race and is seeking reelection to an office he only won by a minuscule margin in 2013.

If Northam performs well, a second consecutive Democratic sweep of Virginia’s three statewide executive offices is in reach. In addition, Democrats will try to make gains in Virginia House of Delegates, the lower chamber of the state’s General Assembly, where all 100 seats are up in November. Republicans currently hold a dominant 66-34 majority, so Democrats would need to net 17 seats to take control, the exact number of Republicans who hold districts Hillary Clinton carried in the presidential race last year, according to calculations by Daily Kos Elections. Democrats, meanwhile, do not hold any seats Donald Trump won, and they shouldn’t have much trouble defending the districts they already control. Winning a majority in the chamber does not seem realistic for Democrats at this point, but if the statewide races break their way, solid coattails could make significant gains possible. The race that seems likeliest to get the most attention features an immense culture clash: anti-gay rights social conservative Del. Bob Marshall (R, HD-13) versus his transgender opponent, journalist Danica Roem (D), in a Northern Virginia seat Clinton carried by 15 points.

In the aftermath of his narrow loss, Stewart remained defiant, refusing to concede and saying “There is one word you will never hear from me, and that’s ‘unity.’” Gillespie should be able to rely on reasonably strong GOP base support, but if Stewart’s backers don’t show up in full force, Gillespie will be in trouble. The GOP statewide primary also featured a nasty, close race for lieutenant governor, with state Sen. Jill Holtzman Vogel winning the nod. Attorney John Adams (R), unopposed for the attorney general nomination and virtually unknown, rounds out the ticket.

Gillespie’s greatest ally — and Northam’s richest nemesis — is the Republican Governors Association, which of all the big-spending partisan third-party groups has probably been the most consistently successful over the past many cycles. The RGA should be all-in on behalf of Gillespie, who is a favorite of national GOP leaders, and the committee could make the difference in a close race. McAuliffe benefited from a big resource advantage over 2013 GOP nominee Ken Cuccinelli (R) in part because Cuccinelli turned off some of the party’s largest funders. Gillespie faces no such perception problem among big-time Republicans, many of whom probably regret not helping him more in his closer-than-expected 2014 Senate loss. Republicans hope that Perriello pushed Northam to the left in this campaign and that Gillespie can seize the middle ground.

For 2017 to be a success for Democrats, they need to capture both open gubernatorial races in New Jersey and Virginia. Phil Murphy (D) appears to be a strong favorite in the Garden State after winning his primary last week, and Northam starts as a smaller favorite in the more competitive Old Dominion. State party leaders in both New Jersey and Virginia — the so-called establishment in both states — got the candidates they overwhelmingly preferred through their respective primaries. Now, will those candidates deliver?

We shall see. As one senior Democrat told us after Northam clinched the nomination and we announced our ratings change on Tuesday night, “Good thing you only went to Leans D and no further. Hell, we’re Democrats, and we’ve got plenty of time to [expletive deleted] this up!”

In other words, despite their recent good fortune in Virginia, Democrats should not take anything for granted.

Table 2: Crystal Ball gubernatorial ratings change