MADISON, Wis. (AP) — Dane County Circuit Judge Jill Karofsky defeated conservative Justice Dan Kelly to win a 10-year term on the Wisconsin Supreme Court in results released Monday from last week’s chaotic spring election.

The race was officially nonpartisan, but the high court has become heavily politicized in recent years. Liberal groups poured more than $2.4 million into the race for Karofsky, while conservatives spent more than $2.5 million for Kelly — who also drew President Donald Trump’s endorsement.

Karofsky’s victory narrows the court’s conservative majority to 4-3 and gives liberals a shot at seizing control when the next seat comes open in 2023.

Karofsky spent most of the campaign on the offensive, accusing Kelly repeatedly of being corrupt for consistently siding with conservative groups that come before the court. Kelly accused Karofsky of slandering him, and the court’s other conservatives questioned her ethics.

Wisconsin was the only state with an April election that didn’t postpone it to protect voters and poll workers from the coronavirus. Democratic Gov. Tony Evers issued a last-minute order on April 6 postponing in-person voting to June but the state Supreme Court struck the order down within hours. Kelly recused himself from that decision because he was running.

The election went on as planned on April 7. But the shifting deadlines forced many voters to decide between sitting the election out or venturing to the polls to cast their ballots in-person and risk contracting the virus.

THIS IS A BREAKING NEWS ALERT. AP’s earlier story is below.

Wisconsin’s bitter state Supreme Court race was close in early returns Monday, as conservative Justice Dan Kelly and liberal challenger Jill Karofsky vied in an election with implications for the ideological makeup of the court.

At stake was a 10-year term on the highly politicized court, which sided with Republicans in holding last week’s election despite widespread concerns about the coronavirus threat.

Conservatives hold a 5-2 advantage, meaning control wasn’t at stake with the result, but liberals were hoping for a Karofsky victory to shift the court at least slightly their way. If so, their next chance to flip the court would come in 2023.

Outside liberal and conservative groups spent a record amount trying to sway voters ahead of a most unusual election that saw record-high absentee ballots submitted and long lines at the polls due to consolidation caused by a shortage of workers amid the coronavirus outbreak.

Municipal clerks across the started counting ballots from the April 7 election at 4 p.m. Monday, six days after the election, in an unprecedented timetable that resulted from the court fight over whether to hold the election.

The race between Kelly and Karofsky, a Dane County circuit judge, was nonpartisan in name only. In a marker of the stakes, the race drew the attention of President Donald Trump, who endorsed Kelly and tweeted his support.

Since conservatives have held a majority on the state Supreme Court, the Republican-dominated Legislature has been able to enact laws that enhanced the GOP’s position, including a voter ID requirement and limits on labor unions, despite legal challenges from Democrats.

Redistricting — the once-a-decade redrawing of congressional and legislative districts that has huge implications for political power — is widely expected to be the next big fight before the court.

Wisconsin stood apart from other states in sticking to its spring election date despite concerns about the danger to voters and poll workers from the virus. After the Republican-controlled Legislature refused to move the election, Democratic Gov. Tony Evers tried to do it himself, only to be overruled by the state Supreme Court.

Kelly didn’t participate in the court’s ruling but advocated publicly for proceeding with the vote.

Recent Supreme Court elections have been very close, with a recount in 2011 and one of the closest races in state history last year.

Karofsky tweeted a plea for donations to her campaign legal fund just hours before the ballots were to be counted, hinting at a possible recount or legal action by saying “we need to be ready to fight back against voter suppression and make sure votes are counted.”

Conservative outside groups supporting Kelly, who was endorsed by President Donald Trump, spent more than $2.5 million, while liberal groups backing Karofsky spent more than $2.4 million, according to a tally by the Wisconsin Democracy Campaign.

Karofsky accused Kelly of being corrupt, alleging that he always sides with conservative groups when they come before the court. Kelly accused Karofsky of slandering him and the entire court; his conservative colleagues issued statements saying Karofsky’s bad behavior shows she’s not fit to serve on the court.

___

Associated Press writer Scott Bauer contributed to this report.

___

Follow Todd Richmond on Twitter at https://twitter.com/trichmond1