It was the boost they needed. The jubilation of Democrats as they celebrated the results of Tuesday’s elections owed much to the despair of one year before, when they learned that Donald Trump was on his way to the White House, as well as to the extraordinary events since, which have amplified his unfitness for the presidency and the extent of Russian meddling in his favour. Though his name was not on the ballot this time, he loomed large in voters’ minds. In Virginia and elsewhere, suburban, college-educated and minority voters surged to the polls to defeat Republicans in an anti-Trump vote.

The Democrats scored hefty victories in gubernatorial races in New Jersey and Virginia, despite fears they could lose the latter, and grabbed a swath of seats in Virginia’s House of Delegates. They swept multiple mayoral races around the country and took control of the Washington state Senate. In Maine, voters approved an expansion of Medicaid under Obamacare.

The big picture was studded with piquant local ripostes to Trumpism. In Virginia, Danica Roem became the first openly transgender candidate to be elected to a state legislative body, defeating self-proclaimed “chief homophobe” Bob Marshall. Wilmot Collins, who arrived in Montana as a Liberian refugee, became its first black mayor. Ashley Bennett ran for office after a politician in a New Jersey county mocked the Women’s March on Washington: Would it end “in time for them to cook dinner”? Now she has served up political revenge, unseating him.

Of course, the Democrats were expected to win in most of the big contests, albeit not by such a margin. Demographic changes helped them in Virginia, and the race for the governor’s mansion should never have been so close. In 2016, Mr Trump lost the popular vote by three million; he was running against a polarising candidate; and now, as his administration piles scandal upon scandal while failing to realise key campaign promises, his ratings are at a historic low.

Even so, the results will raise morale, especially after disappointments such as Georgia’s special election this summer. They demonstrate that anti-Trump energies and activism can translate into electoral success. Polling analyst Nate Silver says they are “favourites, but not heavy ones” to take the House in next year’s mid-terms.

The results are concentrating Republican minds, though it is not yet clear what conclusions they will draw. The Virginian gubernatorial candidate ran a “Trumpism without Trump” campaign, embracing shrill populism without mentioning the president. Did he lose because he is an establishment Republican who tried to dissociate himself from Mr Trump – or because he did not dissociate himself from what Mr Trump stands for?

That the Democrats mostly pulled together for these contests is encouraging. But the party remains divided, with apparently endless recrimination in the upper ranks about what went wrong in 2016 and profound disagreements about the path ahead. Fundamental questions about how to address the capture of politics by the very wealthy, the destruction of the social contract and the fracturing of American society can too easily be reduced to narrow wrangles over which slice of the electorate to target. Celebrations are understandable after a year of gloom, but Democrat glasses should at best be half-full.