MADISON, Wis. (AP) — The Wisconsin Supreme Court race that liberals needed to win to have a shot at taking majority control of the court next year could go to a recount, and the conservative candidate declared victory Wednesday with a narrow lead after the election.

A win would increase the conservatives’ majority to 5-2 and extend their decade-long control of the court 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, Walker’s chief legal counsel for five years, led liberal-backed Lisa Neubauer by 5,962 votes out of 1.2 million cast. That’s a difference of about half a percentage point, close enough for Neubauer to request a recount, but she would have to pay for it.

Hagedorn declared victory early Wednesday morning, calling his margin insurmountable. At a news conference later in Pewaukee, he said a recount “would not make a whole lot of sense,” but said he was ready if it came to that.

Neubauer quickly began fundraising for the recount.

Hagedorn’s performance was a surprise after Neubauer outraised him and drew heavy support from outside spenders. Hagedorn also found himself defending himself over long-ago blog writings, including calling Planned Parenthood a “wicked organization” and denouncing court rulings that favored gay rights.

He said those attacks may have motivated his supporters.

“Without question many of the attacks on me where misleading and inaccurate and lies and smears and I’ve said that throughout this campaign. But the good news is, people didn’t buy those,” he said.

Counties will canvass the vote starting next week to determine the official margin of victory. They have until April 12 to report their results, and Neubauer has three days after the final report to request a recount.

It would likely be expensive and might be futile. Wisconsin recounted the 2016 presidential race at Green Party nominee Jill Stein’s expense. Only 131 votes shifted out of nearly 3 million ballots, and it cost local election clerks $2 million — more than Neubauer raised for her entire campaign.

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.

This year’s race, the only statewide election of the year, was viewed as a barometer of voter mood heading into the 2020 presidential year, where Wisconsin is widely seen as a pivotal state. Turnout was strong at nearly 27%, beating the 2018 Supreme Court turnout of 22%, and Republicans quickly seized on the result as a positive sign for next year.

Hagedorn’s victory 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.

The Wisconsin Supreme Court has been the final word in some of the most partisan battles in the state over the past decade. It has upheld several polarizing laws passed by the Republican-controlled Legislature and was expected to be at the center of battles between Democratic Gov. Tony Evers and GOP lawmakers.

With that dynamic, interest and spending was intense on behalf of the candidates, both appeals court judges.

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.

Walker, who lost by just over 1 percentage point in November, went on conservative talk radio for hours the day before the election to push Hagedorn.

Hagedorn, an evangelical Christian, spent much of the race defending his conservative beliefs. Opponents have pointed to a blog he wrote as a law school student in the mid-2000s in which he called Planned Parenthood a “wicked organization” and denounced court rulings favoring gay rights by likening homosexuality to bestiality. They have also pointed to his founding of a conservative private school that allows for expelling students who are gay. Hagedorn was also paid $3,000 to give speeches at meetings of the Alliance Defending Freedom, a group that supported criminalizing sodomy and sterilizing transgender people.

The winner will serve a 10-year term and replace retiring liberal Justice Shirley Abrahamson, who is 85.