The size of their victories in governor’s races in New Jersey and, especially, Virginia were widely interpreted as a powerful backlash to President Trump, and a blaring warning for suburban Republicans as the GOP tries to keep control of Congress next year.

Arriving one year after Trump’s surprise election victory, the campaigns that concluded Tuesday amounted to a live test of methods, messages, and mood as both parties grope for ways forward.

Could a more moderate Democrat, Virginia’s Ralph Northam, connect with liberal voters? Or did Democrats need a more combative voice to rally their base against Trump?

Could a Virginia Republican with a traditional background — the Mount Laurel, N.J.-born Ed Gillespie, former chairman of the Republican National Committee — win over the Trump coalition by driving at cultural issues like immigration and Confederate statues? Or had the president’s style alienated the moderate voters who swing elections?

Though the campaigns invoked Trump to widely varying degrees, the president has loomed over all politics since his stunning victory last year. The results Tuesday were an affirmation of Democratic voters’ motivation and an indication that Trump’s low public approval could hurt his party.

“Fear and division and hatred do not work,” Virginia Gov. Terry McAuliffe, a Democrat, said on CNN. They didn’t work in Virginia “and they do not work in America.”

Of particular concern for Republican incumbents in Philadelphia suburbs could be Democratic routs in the wealthy, well-educated areas just outside of Washington, which in many ways mirror places like Chester and Delaware Counties, where critical congressional races loom. Such races could determine control of the House.

Of course, it was just a handful of races in New Jersey, Virginia, and elsewhere, and Democrats had been expected to win the two big gubernatorial contests. Both states supported Democrat Hillary Clinton last year and a Democratic loss in either would have been calamitous for them.

But few expected the blowout that emerged in Virginia. Not only did Northam win, but Democrats made major gains in the state legislature — taking more seats from Republicans than in any race since 1899, according to Democrats.

Among the victors was Chris Hurst, a former news anchor in Virginia who grew up outside Philadelphia and turned to politics after his girlfriend, a reporter, was shot and killed while on television. Hurst unseated a Republican incumbent in a district based in Blacksburg.

In Maine, voters approved an expansion of Medicaid, adopting a policy championed by Democrats.

Republicans said not to read too much into the results. Campaigns hinge on individual candidates, they noted, and there is a year to go before the next election.

“Ed Gillespie worked hard but did not embrace me or what I stand for. Don’t forget, Republicans won 4 out of 4 House seats,” Trump tweeted after the results came in, referring to previous special congressional elections where Republicans prevailed. “With the economy doing record numbers, we will continue to win, even bigger than before!”

Josh Novotney, a Republican consultant from Philadelphia, chalked up the size of the Democratic win to the work of the individual campaigns, rather than any broad sign.

Other election analysts saw signals in the massive Democratic margins in suburban areas — continuing a trend that began last year when Trump surged with rural, blue-collar voters, but struggled in wealthier, highly educated areas.

In Loudoun County, a Washington suburb in Northern Virginia, Gillespie won around 40 percent of the vote — compared with 49 percent when he narrowly won the county as a U.S. Senate candidate in 2014, to choose one key example.

“Anger’s such a great motivator,” said Kyle Kondik, referring to the Democratic reaction to last year’s Trump victory. Kondik, managing editor for Sabato’s Crystal Ball, a University of Virginia election forecasting site. “In terms of the competitive suburbs where there are a lot of competitive House races, this is like a flashing red warning sign.”

“Canary in the coal mine, Trump apologists,” tweeted Julie Roginsky, a Democratic consultant from New Jersey, as the Virginia race was called far earlier in the night than most expected.