Democrats won up and down the ballot Tuesday night, notably in the governors' races in Virginia and New Jersey. The victories were a much-needed sigh of relief for a party that hadn't had any high-profile victories at the ballot box during the first year of the Trump presidency — despite his record-low approval ratings.

Here are seven takeaways from what happened Tuesday and what it means:

1. The resistance can win. Voters delivered Democrats their first rebuke of President Trump at the ballot box during his presidency. Before Tuesday night, Democrats had shrunk the margins in multiple special elections but came up short. Tuesday's results will give what were nervous Democrats some much-needed confidence.

2. Trumpism has its limits. Democrats were able to hold the line and made inroads in suburban areas rich with professionals and those with college degrees. Tuesday's results will be a big warning sign for any elected Republican in a Democratic or moderate-leaning state or district. Both governors' races were rife with incendiary ads hitting on cultural issues and crime.

Despite Trump's warning that Republican Ed Gillespie didn't hew closely enough to Trumpism, the president was unpopular at the ballot box.

Almost 6 in 10 Virginia voters said they disapproved of the job Trump was doing (57 percent), according to exit polls, and twice as many people said they were motivated to go to the polls to reject him than those motivated to support him.

"I do believe that this is a referendum on this administration," Republican U.S. Rep. Scott Taylor of the swing Virginia Beach area told The New York Times. He blamed Trump's "divisive rhetoric" for the sweeping losses statewide.

Democrat Ralph Northam won by 9 points, the widest victory for a Democrat in the governor's race since Gerald Baliles won by 11 points in 1985, when the state was very different.

Watch for elected Republicans in these kinds of areas to give a second thought to using the kinds of Trumpian tactics that Gillespie, and to an extent Republicans in New Jersey, used. Remember: Trump lost Virginia and New Jersey, so being more like Trump in those areas doesn't make a whole lot of sense.

3. A shifting of old political lines continues. Democrats upped their margins in Northern Virginia and formerly swing suburban counties. Meanwhile, Democrats continued their slide in rural, western Virginia.

4. Progressive platform gets a boost. Danica Roem in Virginia became the first openly transgender person elected to a statehouse in the country. And the 33-year-old did so over 13-term incumbent Bob Marshall, who authored Virginia's "bathroom bill" and considers himself the state's "chief homophobe." What's more, the election took place in Prince William County, which George W. Bush won by 7 points in the 2004 presidential election, but Hillary Clinton won by 21 points in 2016.

Chris Hurst, the boyfriend of a reporter shot and killed on live TV, won a seat to the Statehouse in Virginia on a gun-control platform over three-term NRA-backed incumbent Joseph Yost.

And, in New Jersey, the city of Hoboken, just outside New York City, got its first Sikh mayor. Ravi Bhalla, a Indian-born city councilman, faced racist attacks, including a poster that stirred statewide controversy. With Bhalla's face on it, the poster read, "Don't let TERRORISM take over our town!" During remarks at a victory party Tuesday night, Bhalla said, "Thank you for having faith in me, for having faith in our community, faith in our state, and faith and in our country; this is what America is all about."

Voters also supported Medicaid expansion by referendum in Maine, doing an end run around Republican Gov. Paul LePage's veto. Expect other states to follow Maine's lead.

Expansion of the Affordable Care Act has been made far more likely thanks to Democratic gains in Virginia with Democrats controlling all the statewide offices and being very close to taking over the Statehouse. (There will be recounts.)

And, by the way, while Democratic voters appeared motivated statewide — there was a 16 percent increase in turnout from the 2013 governor's race — it was even higher in Charlottesville, the site of white nationalist protests this summer that resulted in a woman's death. Trump had stoked controversy by saying there were "fine people" on both sides of the protests, which included white supremacists, neo-Nazis and the alt-right. Charlottesville saw a 31 percent increase in turnout. For perspective, Northam won more votes in Charlottesville this year than the total number of votes cast in 2013 in the city.

5. Get ready for close and contentious 2018 and 2020 elections. Consider last night a warmup. For those who say nothing seems to matter when it comes to Trump and what he does or says, this shows that line of thinking is just not true. No president has been more unpopular at this point in his presidency since polling began. Remember, Hillary Clinton did win the popular vote by 3 million votes, and there is a reason for that. Virginia is very reflective of the country. Tuesday night shows 2020 certainly is shaping up to be a contentious election — and no cakewalk for this president.

6. At the same time, Democrats should be careful about overanalyzing the results. You never want to read too much into off-year elections. You never know what the landscape will look like in a year, and Virginia and New Jersey are states Clinton won. The trend of Virginia going from red to purple to reliably blue is now clear. In other words, Democrats are supposed to win there.

The wins should help Democrats hit the reset button and regroup, but Tuesday night's results by no means guarantee Democrats are going to take back the House or Senate. The districts are still very much drawn in Republicans' favor, and they have a very favorable Senate map.

What's more, Democrats would probably be making a mistake if they think Tuesday night's results mean they can win in the places they lost and need in 2018 and 2020 on strictly an anti-Trump and progressive platform.

Tuesday night reinforces that this is a sharply divided country.

7. Voting matters. One of the big stories of the night is that Democrats are one seat shy of taking back the state Legislature in Virginia. If they were to do that and hold it in 2019, it would give them the ability to redraw congressional districts in 2021.

Currently, there are several races that are likely going to a recount, including one in which the Republican candidate is up by just 12 votes.

Other individual legislative races are separated by 68, 86, 124, 326 and 394 votes.

It shows that for all those who are agnostic or apathetic about politics, voting matters, especially at the local level. And voters turn out in much higher numbers in presidential elections.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.