This story is part of our elections coverage. Read our list of the most important races and ballot measures to watch here.

Democrats have been looking to Virginia all year to set the stage for what they hope will be big gains at the state level in 2018. But they may be disappointed.

Democrats have heavily recruited candidates for the Virginia House, where the GOP currently holds a nearly 2-to-1 majority. They're likely to make some gains there, but the November elections will be considered a failure for the party if Democratic Lt. Gov. Ralph Northam doesn't win the governor's race to replace term-limited Democratic Gov. Terry McAuliffe.

Nationwide, Republicans hold 34 governor's offices, a historically high majority, and have control of twice as many state legislative chambers as Democrats. 

In Virginia, most polls have shown Northam ahead of Republican opponent Ed Gillespie, a former chair of the state and national GOP. In a Christopher Newport University poll released Monday, Northam had 49 percent of voters' support, while Gillespie had 42 percent.

But Northam can't rest easy.

"My gut tells me this is a margin-of-error race," says Quentin Kidd, director of the Wason Center for Public Policy at Christopher Newport.

Gillespie has run an aggressive campaign against Northam, who has yet to catch fire among many Democrats. Republicans in the commonwealth like to point out that their candidates often finish ahead of their polling results -- including Gillespie himself, who wasn't considered a factor in the 2014 U.S. Senate race but ended up finishing within a single percentage point of unseating Democrat Mark Warner.

"By nature, conservative voters tend to hold things closer to their chest," says Republican state Sen. Frank Ruff. "Generally, you're going to see those undecided voters breaking to the more conservative candidate."

In New Jersey -- the only other state holding a gubernatorial election this fall -- Democrats can rest easier. President Trump and term-limited GOP Gov. Chris Christie's approval ratings are anemic there, sinking the hopes of the GOP candidate, Lt. Gov. Kim Guadagno. The Democrat, former Goldman Sachs executive Phil Murphy, has a comfortable double digit lead in the polls.

"Everything is bending in Murphy's direction, without even considering the role of antipathy to Trump," says John Weingart, associate director of the Eagleton Institute of Politics at Rutgers University. "New Jersey voters are very tired of Chris Christie, making the path difficult for his lieutenant governor."

In Virginia, Gillespie has been working all year to unite Republicans behind him. A longtime Capitol Hill aide, party official and lobbyist, Gillespie is a classic "establishment" politician. He was nearly upended in the GOP primary by Corey Stewart, who chairs the Prince William County Board of Supervisors and ran on divisive cultural issues, such as support for Confederate monuments. Gillespie, however, has since expressed his support for Confederate monuments and seems to have won over most of the party faithful by doing so.

Northam, who is considered a moderate Democrat, fended off a primary challenge from his left launched by former U.S. Rep. Tom Perriello. Northam has adopted progressive positions on issues such as criminal justice reform and the minimum wage, but he has faced complaints from environmentalists, notably that he has failed to condemn two natural gas pipelines that have been proposed in the state.

"There are certainly a number of Democrats who wish Ralph Northam were more liberal, but there's little evidence that they're willing to see Gillespie become governor in order to send a message from the Democratic left," says Stephen Farnsworth, a political scientist at the University of Mary Washington. "When politics are as partisan as they are, you're looking at a situation where the other side is so unappealing that whatever differences that existed in the primary are papered over to make sure your tribe prevails."

The race has certainly turned negative.

Late last month, Gillespie rolled out a series of ads that sought to associate Northam with the MS-13 gang and criticized his record on immigrant "sanctuary cities" (which Virginia bans). Gillespie has been accused of engaging in racist dog-whistle politics with the ads. The Washington Post, for example, editorialized, "Mr. Gillespie has twisted truth to suit his purpose, and pandered to nativists in the Republican base."

Trump echoed the Gillespie campaign's message, tweeting last Thursday, "Ralph Northam, who is running for Governor of Virginia, is fighting for the violent MS-13 killer gangs & sanctuary cities. Vote Ed Gillespie!"

When it comes to Trump, Gillespie is performing a delicate dance. He's looking for the president to help him among die-hard supporters while not embracing him too closely, given his unpopularity in Virginia. 

Northam, meanwhile, is hoping his natural advantages will prevail. McAuliffe's approval rating is above 50, and Northam has been able to raise more money thus far than the well-connected Gillespie. History is also on Northam's side: Virginia has shaded more blue in recent years, supporting Barack Obama for president twice and Hillary Clinton over Trump last fall, and the state has elected governors from the party that lost the White House the previous year in nine of the last 10 elections, dating back to 1977.

"The party that loses the White House tends to be very motivated when Virginia votes a year later," Farnsworth notes. "Politics seems to be motivated a lot these days by anger."

Democrats, of course, are hoping that anti-Trump anger will be a huge motivating force for their base. So far, that's proven largely true this year in special legislative elections in other states. In about three-dozen races this year, Democrats have picked up eight seats, compared with one for the GOP. What's more, the winning Democrats have tended to outpace Clinton's performance in their districts last year.

In Virginia, Democrats need to gain 17 seats to win control of the chamber. As it happens, there are 17 seats held by the GOP in districts that Clinton carried. Sweeping them all is highly unlikely, but most observers think Democrats will pick up a handful of seats.

"Seventeen seats is an insane lift for one cycle," says Carolyn Fiddler, politics editor for Daily Kos, a liberal website that raises money for Democrats. "It would take a ridiculous wave. But a pickup of a good chunk of that in one cycle would put it in play ahead of redistricting."

In recent election cycles, Virginia Democrats have largely ceded control of the state House to the GOP, not even running candidates in 40 or more of the 100 seats. That's not the case this fall. Democrats are running candidates in 88 of the races.

The mere fact that they're running candidates nearly everywhere could have a "bottom-up" effect that boosts Northam, Farnsworth says.

"By having a lot of aggressive Democratic challengers, particularly in suburban areas, you're going to see a lot of door-knocking and Democratic Party-contacting that you normally don't see at the House of Delegates level," he says.

Such contact, he says, might be crucial.

"One of the challenges that both campaigns are facing this year is to get much in the way of media or public attention," Farnsworth says. "Donald Trump has so dominated the news, it's a struggle for either candidate to be heard in what is the biggest political race in the country this year."

This story is part of our elections coverage. Read our list of the most important races and ballot measures to watch here.