Virginia's off-year elections later this year — when 140 legislative seats and partisan control of the Legislature is up for grabs — may signal what the rest of the country's mood will be in 2020. But a series of surprising primary results Tuesday offered mix messages on what voters want.

The progressive wing of the Democratic party flexed its muscles in some races and faltered in others. Conservatives unhappy with moderate Republicans who backed Medicaid expansion last year took out one target and whiffed on another.

Once a key swing state that's been tilting increasingly toward Democrats, Virginia's 2017 elections were an early warning signal that a blue wave of opposition to President Donald Trump would wash over the 2018 U.S. midterms. Only four states are having legislative elections this year and Virginia is the only one where Democrats have a chance of flipping control of the House and Senate, where Republicans currently have narrow majorities. Both parties are hoping to use this year's contests to send a message about next year's presidential and congressional races.

Normally sleepy affairs, this year's primaries had drama, as moderates in both parties took fire from their more extreme flanks.

Get Breaking News Delivered to Your Inbox Click here to view related media. click to expand

On the Democratic side, Senate Minority Leader Dick Saslaw faced his first challenge in four decades and nearly lost to human rights lawyer Yasmine Taeb despite having a massive cash advantage.

"The other guy's been in there too long," said John Laszakovits, a 60-year-old engineer from Falls Church, who said he voted for Taeb.

"I'm not gonna lie. It was closer than I thought it was going to be," Saslaw said in a brief interview at his victory party.

He attributed the close nature of the race to the momentum for candidates who promise change. "People want new," he said.

In a sign of unease with established Democratic politicians on the local level, two long-tenured northern Virginia prosecutors lost to reform-minded challengers intent on making changes to what they view as a heavy handed criminal justice system. Parisa Dehghani-Tafti defeated incumbent Commonwealth's Attorney Theo Stamos in Arlington County and Steve Descano unseated incumbent Raymond Morrogh in Fairfax County.

But every other Democratic state lawmaker, except for one, was easily able to fend off a challenger. Joe Morrissey, who was jailed four years ago after a sex scandal involving a teenager he later married, defeated incumbent Sen. Rosalyn Dance in a Richmond-area senate district. That victory was more a sign of Morrissey's enduring popularity than anything else.

On the GOP side, lingering resentment over last year's vote to expand Medicaid in Virginia fueled divisive contests.

Republican voters in a swing district punished Del. Bob Thomas, who voted for the expansion. They opted instead for a more conservative challenger, Paul Milde, who could make it harder for Republicans to keep their majority in the House.

But Republican Sen. Emmett Hanger, one of the state's most powerful senators, easily defeated his opponent.

Hanger played a key role in the Medicaid expansion that made 400,000 low-income adults eligible to enroll. Opponent Tina Freitas said Hanger had betrayed constituents on the Medicaid issue and wasn't conservative enough on guns or abortion. Hospitals spent heavily to help Hanger.

Both parties said they are feeling optimistic about their chances in the general election. Democrats are hoping anti-Trump energy powers them to victory and they've shown an eagerness to run in seats they've traditionally ignored, including in southeast Virginia where three Democrats fought to run in a district Trump won by 14 percentage points in 2016.

Republicans were cheering Tuesday's turnout in key districts. More people voted in the Republican primary than in the Democratic primary in an open Virginia Beach Senate district that could determine the upper chamber's balance of power.

Republicans were also counting on a wave of scandals earlier this year involving the state's top Democrats to help GOP candidates.

A racist yearbook photo that surfaced in February almost forced Gov. Ralph Northam from office. Lt. Gov. Justin Fairfax was then accused by two women of sexual assault, which he denied. And Attorney General Mark Herring, after calling for Northam to resign, revealed that he too wore blackface once in college.

Morrissey's victory is likely to add a significant new headache for Democrats eager to move past those scandals. Republicans wasted little time trying to exploit Morrissey's victory, tweeting a sarcastic congratulatory note and adding "You'll fit right in with Justin Fairfax."

But voter Melvin Washington said he picked Morrissey because he believes he understands the district's neighborhoods, and Washington said he is not bothered by Morrissey's past legal problems.

"People try to blow things up more than what it is," he said. "Ain't none of us perfect."