Lisa Neubauer speaks about her race against fellow appeals-court Judge Brian Hagedorn.Scott Bauer / AP

A funny thing happened Tuesday to the Democrats’ momentum in Wisconsin: It sputtered out. Despite being heavily favored to win a crucial seat on Wisconsin’s Supreme Court, the candidate backed by liberal groups was apparently upset by a conservative. This still unofficial result should serve as a warning to national Democrats, especially when it comes to the issue of religious liberty.

The Wisconsin judicial race was close enough to trigger a recount, but the likely eventual defeat of Judge Lisa Neubauer by Judge Brian Hagedorn means that conservatives will continue to control the state’s highest court for the foreseeable future. If Hagedorn’s victory holds up, conservatives will hold a 5–2 majority on the court, dashing liberal hopes that they might flip the court by beating an incumbent conservative next year.

Even though the position she sought is officially nonpartisan, Neubauer was endorsed by state and local Democrats. Former Democratic Attorney General Eric Holder visited the state to campaign on her behalf. Both Democrats and Republicans expected her to win easily, especially after a major business group, the Wisconsin Realtors Association, withdrew its support from Hagedorn last month. Until the final week of the campaign, reported the Wisconsin Democracy Campaign, “Democratic-leaning groups backing Neubauer had dominated outside spending by as much as 14-to-1.”

A Neubauer victory would have continued a blue pattern in the state, extending back to a decisive win by a liberal candidate for a seat on the state Supreme Court last spring and through to last November’s gubernatorial contest, in which the Democrat Tony Evers ousted the Republican Scott Walker.

Until Tuesday, Democrats seemed to enjoy a clear advantage in enthusiasm in Wisconsin. Opposition to President Donald Trump fueled massive voter turnout in Madison and Milwaukee last fall, and that energy showed no signs of abating. Republicans were seen as discouraged and disheartened.

So what happened?

“The base woke up,” one GOP official texted me.

A backlash built against attacks on Hagedorn for his involvement in founding a Christian school. Critics charged that the school, the K–8 Augustine Academy in Waukesha County, banned LGBT students and staff, because its code of conduct banned “immoral sexual activity.” The code defined that as “any form of touching or nudity for the purpose of evoking sexual arousal apart from the context of marriage between one man and one woman.” Hagedorn was also criticized for speaking with social conservative groups such as the Alliance Defending Freedom, and for suggesting that he agreed with the late Justice Antonin Scalia’s dissent in a Texas case overturning anti-sodomy laws. In a blog post, Hagedorn wrote, “The idea that homosexual behavior is different than bestiality as a constitutional matter is unjustifiable.” He also wrote in a 2005 blog post that “Christianity is the correct religion, and that insofar as others contradict it, they are wrong.”

The controversy is what led the state realtors to rescind their endorsement of Hagedorn. But Hagedorn pushed back, insisting that he was being attacked for his religious faith, and social conservatives rallied around him. “Some of the arguments made against me are a blatant attempt not just against me but against people of faith more generally," Hagedorn said at a campaign event.

“The backlash was overwhelming,” one Republican activist told me. “The left made this about bigotry, but Christians saw this as an attack on their faith.” Others saw a replay of attacks on Justice Brett Kavanaugh, which helped turn out Republican voters last fall.

As central as the fight over religion was, Republicans in Wisconsin cited two other major factors in the conservative resurgence.

After a controversial lame-duck legislative session, liberal groups got a judge from liberal Dane County to invalidate the entire legislative session, including all the appointments made by then-Governor Walker and confirmed by the legislature. The decision has since been stayed by the court of appeals and is likely to be overturned, but the sweeping ruling revived memories among Wisconsin Republicans of previous judicial rulings that sought to invalidate other conservative victories.

In Wisconsin, nothing motivates Republican voters like activist judges from liberal Madison, and the decision on the legislative session dramatized the importance of judicial elections for conservatives.

Meanwhile, Evers has gotten off to a shaky start. After claiming late in the gubernatorial campaign that he was not looking to raise taxes, Evers’s first budget proposed more than $1 billion in tax hikes. This development led Republican legislators to report a surge in campaign contributions.

Perhaps none of this would have made a difference if not for a big, last-minute ad buy on Hagedorn’s behalf. But, clearly, Republicans responded to what they saw as unfair attacks on Hagedorn and Democratic overreach. Turnout in GOP areas was up sharply from last spring’s judicial election. Hagedorn appears to have ridden a wave of votes from northern and north-central Wisconsin that counteracted Neubauer’s margins in Dane and Milwaukee Counties.

This upset should serve as a warning to Democrats, but it’s certainly not a reliable predictor of what will happen in 2020. As Wispolitics’ J. R. Ross noted, Wisconsin conservatives scored a major victory in the April 2008 state Supreme Court election, when Judge Michael Gableman ousted the liberal incumbent Justice Louis Butler by winning 51.2 percent of the vote.

Later that year, Barack Obama won Wisconsin with 56.2 percent of the vote.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.