MADISON, Wis. — The Wisconsin Supreme Court race that liberals needed to win to have a shot at taking majority control of the court next year appeared headed for a recount, with the conservative candidate declaring victory while holding a narrow lead following Tuesday’s election.

A conservative win would increase their majority to 5-2 and ensure their control over the court, which they’ve held since 2008, until at least 2023.

It would be a particularly stinging defeat for liberals, who were confident and riding a wave of wins in 2018, including picking up a Supreme Court seat and ousting Republican Gov. Scott Walker.

Conservative Brian Hagedorn, who was Walker’s chief legal counsel for five years, led liberal-backed Lisa Neubauer by 5,911 votes out of 1.2 million cast, based on unofficial results. That is a difference of about 0.49 percentage point, close enough for Neubauer to request a recount, but she would have to pay for it.

Hagedorn declared victory early this morning, issuing a statement that said: “The people of Wisconsin have spoken, and our margin of victory is insurmountable.”

Minutes after he declared victory, the Neubauer campaign sent out a fundraising plea, saying that “with the vote total neck and neck, it looks like we’re heading into a potential recount.” Her campaign adviser, Scott Spector, said this morning that Hagedorn’s declaration of victory did not change their position that a recount was likely.

Counties will canvass the vote starting next week to determine the official margin of victory.

The last statewide election was for the presidential race in 2016 that Donald Trump won by less than a percentage point. In that recount of nearly 3 million ballots, only 131 votes were changed — in favor of Trump. Neubauer, in a recount of just 1.2 million ballots, would have to pick up 45 times as many votes.

The only other statewide recount came in the 2011 Wisconsin Supreme Court race.

Liberal candidate JoAnne Kloppenburg declared victory after preliminary results showed her with 204 more votes than conservative incumbent Justice David Prosser. But the following day, Waukesha County’s clerk said she had failed to report 14,000 votes. In a recount, Prosser won by just over 7,000 votes.

The 2016 presidential recount cost local election clerks $2 million, which is more than the $1.7 million Neubauer raised during the entire Supreme Court campaign. However, those costs included overtime for clerks who had to count nearly 2.9 million votes under a tight deadline due to the Electoral College.

Wisconsin’s Supreme Court race, the only statewide election of the year, was viewed as a barometer of voter moods heading into the 2020 presidential year. Turnout was strong at nearly 27 percent, beating the 2018 Supreme Court turnout of 22 percent, and the tight outcome provides more evidence of how evenly divided Wisconsin is.

Hagedorn’s victory in battleground Wisconsin sends 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,” said Mark Jefferson, executive director of the Wisconsin Republican Party.

Both Neubauer and Hagedorn are appeals court judges and partisan interests played heavy in the race.

Former Democratic U.S. attorney general Eric Holder’s group committed to spending $350,000 to help Neubauer win. A host of conservative groups, including Americans for Prosperity that is part of the Koch network, matched Democratic outside spending to help Hagedorn.