Wisconsin Democrats are back to feeling a familiar sinking feeling.

The liberal candidate for a crucial state Supreme Court election was expected to win on Tuesday night. But conservative Brian Hagedorn emerged from the night clinging to a 5,911-vote lead with 99 percent of precincts reporting, defying the expectations of strategists in both parties. The surprise result, while far from final, is an ominous sign for Democrats who see the state as perhaps the most important on the presidential map in 2020.

The race is likely headed to a recount. But Hagedorn begins that process in a much stronger position than liberal Lisa Neubauer — and if he hangs on, Wisconsin’s Supreme Court will remain in conservatives’ hands for at least another five years.

That would have major policy ramifications in the state on issues expected before the court in the coming years, from gerrymandering to Republicans’ late-2018 power grab laws to voter identification laws and other controversial measures Republicans pushed into law before they lost the governorship last fall.

Republicans took a victory lap.

“Judge Hagedorn’s victory was not only a victory for clean government and the rule of law, but is sure to send shockwaves across the political spectrum,” Wisconsin Republican Party Executive Director Mark Jefferson said in a statement released after 3 a.m. ET Wednesday morning. “Together we sent a message to all of America that we’re ready to keep Wisconsin red as we turn our attention to mobilizing for 2020 and re-electing President Trump.”

Neubauer and her allies downplayed the result, promising a recount fight that could take weeks to resolve.

“We are almost assuredly headed to a recount,”Neubauer campaign manager Tyler Hendricks said in a Tuesday night statement. “Wisconsinites deserve to know we have had a fair election and that every vote is counted.”

But it’s generally very difficult to overcome a gap of more than a few hundred votes in a recount, unless there were some major screw-ups in election-night vote counting that have yet to emerge.

The race was ostensibly nonpartisan. But Hagedorn was a top legal adviser to former Wisconsin Gov. Scott Walker (R) before he became a judge, while Neubauer was a member of a top Democratic family in the state.

The race wasn’t even supposed to be all that close. Liberal groups deluged the state with ads backing Neubauer in recent weeks, including former U.S. Attorney General Eric Holder’s organization, which spent hundreds of thousands of dollars on the race. Hagedorn faced brutal coverage in state over his hostile views on gay rights and controversial writings as a law school student from a decade ago, and was largely left out to dry by conservatives until a last-minute injection of cash from the Republican State Leadership Committee. Even with that million-dollar investment from the RSLC, liberals outspent conservatives on the airwaves by a wide margin in the race, and strategists in both parties told TPM just days before the election that they expected Neubauer would win by a few points.

But in a result eerily reminiscent of the 2016 presidential election in the state, liberals’ heavy focus on social and culture war issues they believed would be disqualifying over pocketbook issues appeared to backfire, as a surge in the vote from more culturally conservative areas around greater Green Bay, exurban Milwaukee and Wisconsin’s Northwoods more than made up for big turnout in Madison, while Milwaukee’s turnout once again lagged behind the state.

Democrats had hoped they’d turned a corner in the competitive state after last year, when they won back the governorship for the first time since 2010 and saw Sen. Tammy Baldwin (D-WI) reelected by a double-digit margin months after winning another state supreme court race by nearly double digits. They thought that was a sign they might have righted the ship heading into the 2020 presidential election, where Wisconsin is one of the three biggest swing states on the map along with Pennsylania and Michigan.

This close result shouldn’t be over-interpreted as a sign the GOP is back on the march in the closely divided state — a close off-year election in April with relatively low turnout isn’t the same as a presidential race, as Republicans saw when President Obama easily won the state in 2012 after the GOP’s big wins across the state just months earlier. And President Trump’s standing in the state isn’t as good as some other Republicans’ due to the damage his trade wars have done to some local industries. But the results show that Republicans are indeed fired up heading forward — and suggest the state will be the ultimate battleground next year.

This story was updated at 8 a.m. ET Wednesday.