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. Still, the conservative candidate declared victory overnight 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, for years to come. 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.

Get Breaking News Delivered to Your Inbox

Hagedorn declared victory early Wednesday morning.

Conservative Brian Hagedorn led liberal-backed Lisa Neubauer by 5,911 votes out of 1.2 million cast, based on unofficial results WISC-TV

"The people of Wisconsin have spoken, and our margin of victory is insurmountable," the Hagedorn campaign said in a statement released just after 2 a.m. Wednesday, CBS affiliate WISC-TV reported.

"I am deeply humbled and honored by the voters who have placed their trust in me to serve as Wisconsin's next Supreme Court justice. The voters chose to have a Court that keeps personal political beliefs out of the courtroom and applies the law as written," the statement said.

Minutes after he declared victory, the Neubauer campaign sent out a fundraising plea saying "with the vote total neck and neck, it looks like we're heading into a potential recount." Her campaign adviser Scott Spector said Wednesday 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 time there was a recount in a Wisconsin Supreme Court race was in 2011.

The last statewide election was for the presidential race in 2016. That 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, more than double the 1.2 million cast in this year's Supreme Court race.

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%, beating the 2018 Supreme Court turnout of 22%, and the tight outcome provides more evidence of how evenly divided Wisconsin is.

President Donald Trump carried the state by less than a percentage point, and Walker lost by just over 1 point.

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.

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.

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.

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.

Neubauer, 61, was appointed to the appeals court in 2007 by former Democratic Gov. Jim Doyle. Neubauer was elected to the appeals court in 2008, re-elected in 2014 and has been chief judge since 2015. She spent almost 20 years as an attorney in private practice. Nearly every judge who endorsed a candidate in the race - more than 340, or 98% - backs Neubauer. Hagedorn won endorsements from the National Rifle Association and Wisconsin Right to Life.

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