Democrats scored two gubernatorial victories Tuesday night that will send them into the midterm elections with confidence that they can chip away at Republican majorities in Washington and maybe even retake Congress.

While the House and Senate races remain a year away, the pivotal off-year gubernatorial elections in Virginia and New Jersey have been predictors of midterm success for both parties in the past. Now Democrats have won them both.

New Jersey was never close. After the collapse of Republican Gov. Chris Christie’s popularity, both in the state and nationwide, Democrats took an early lead in New Jersey and haven’t looked back. Kim Guadagno, the lieutenant governor under Christie, is the GOP nominee. Democrat Phil Murphy led in the final pre-election polls by an average of 14 points and now will be the next governor of the state.

Virginia, by contrast, was a hard-fought affair for months despite early predictions that Democrats would easily retain the governorship. It’s a state President Trump lost in 2016 and where Republicans haven’t won a statewide race since 2009. Democratic Lt. Gov. Ralph Northam led in all the late polls on his way to victory Tuesday night.

Yet Republicans in recent Virginia races have performed better at the ballot box than the last round of polling predicted. Republican Ed Gillespie trailed popular Sen. Mark Warner, D-Va., by an average of 9.7 points in the 2014 Senate race and wound up losing by just 0.8 points. This time, Gillespie was the GOP nominee for governor. Northam’s lead of just 3 points in the final polling wasn't substantial enough to absorb that kind of overperformance, which had Democrats nervous.

This time, however, Democrats had nothing to worry about, as Northam turned in a stronger performance than pollsters predicted.

The Democrats were also still coping with the psychic shock of having lost the 2016 presidential race, another campaign many of them assumed was a sure thing for their party. Northam has drawn comparisons to Clinton. He is seen as uncharismatic, has drawn tepid support from some liberals, and wasn’t supported by voters fond of Sen. Bernie Sanders, I-Vt., in the primary, although Northam did win the nomination by a bigger margin than expected.

None of that mattered Tuesday.

Gillespie, by contrast, was an establishment candidate who tried to keepTrump at a safe distance while following more in the footsteps of former President George W. Bush. He nevertheless ran a series of hard-hitting ads to rally the GOP base and has emphasized some of Trump’s themes: cracking down on illegal immigration, sanctuary cities, and MS-13, while defending Confederate statues that dot the Virginia landscape and criticizing NFL players who do not stand for the national anthem.

This did not help Gillespie enough in the parts of Virginia where Trump is popular while costing him support in the D.C. suburbs compared to his 2014 Senate race.

Democrats criticized Gillespie for running a racially divisive campaign, urging voters to reject racism in the wake of Charlottesville, Va. protests by white nationalists and neo-Nazis. But late in the campaign, they appeared overreach when an outside group ran an ad showing a truck, displaying a Gillespie bumper sticker and a Confederate flag, chasing down minority children. The ad was pulled after a terrorist in New York City actually did run people down with a truck.

The firm that produced the ad defended it Monday night, saying it was necessary to fight back against a political tradition that includes 1988's Willie Horton commercial by George H.W. Bush's campaign.

In her longer shot race in a blue state, Guadagno has also stressed law and order, running as a candidate who is tough on crime and against sanctuary cities. With wins in both states, Democrats will argue that Trumpism is a losing bet for Republicans and shape their 2018 campaign plans accordingly.