Wisconsin voters head to the polls on Tuesday, bringing an end to a viciously fought state Supreme Court race.

Millions of dollars were spent. Conservative candidate Brian Hagedorn, legal counsel to former Gov. Scott Walker, was pilloried for past comments calling the NAACP a “disgrace to America” and comparing homosexuality to bestiality. Former Attorney General Eric Holder visited Madison to campaign for liberal candidate Lisa Neubauer, calling the race something voters “need to be engaged in.”

Much of the political chatter has centered on how much the partisan tilt of Wisconsin’s court matters for the next round of redistricting. After the 2020 census, lawmakers in the bitterly divided state will have their next chance to draw up congressional and state legislative districts. If—or, more likely, when—lawsuits are filed over those maps, the state Supreme Court will have the final word on whether they pass muster.

In swing states from Wisconsin to North Carolina, redistricting has emerged as a focus in these less-covered, increasingly pricey contests. With varying degrees of candor, lawmakers and operatives are making it clear they’re looking at state Supreme Court races with 2021 redistricting in mind.

“The prominence of redistricting in these races is somewhat new,” Douglas Keith, counsel with the Brennan Center’s Democracy Program and an expert on state Supreme Court races, told TPM.

Pointing to contentious district line fights involving the highest state courts in Pennsylvania and Wisconsin, Dave Daley, a redistricting expert with Fair Vote, predicted: “We’re going to see both sides now fighting aggressively over state Supreme Court seats.”

The Pennsylvania example is instructive. In 2018, the Democratic-controlled state Supreme Court ruled that lawmakers’ congressional district lines represented an extreme partisan gerrymander. Republicans said that two of the Democratic justices were unfairly biased, pointing to comments they made during their 2015 campaigns, calling the state’s GOP gerrymander “insane” and for an “end” to gerrymandering, respectively.

After lawmakers failed to meet a court-imposed deadline to draw new districts, the court ordered that its own map, composed by an outside expert, be used. The state GOP erupted, with some lawmakers even calling to impeach four of the body’s Democratic justices for “misbehavior in office.”

The Republican State Leadership Committee cited the Pennsylvania situation as an example of how “the Obama-Holder hit squad” are trying to take over state Supreme Courts “to undermine election outcomes and rig the system for Democrats.” Having courts determine what represents an unfair partisan gerrymander or draw maps usurps the rightful authority of state lawmakers to handle redistricting, the RSLC’s David James told TPM in a recent interview.

Other swing states have seen similarly fierce races. A WRAL report about North Carolina’s 2016 contest was headlined “Supreme Court spending ‘all about redistricting.’” Democratic candidate Mike Morgan prevailed, giving his party a 4-3 majority in the court.

That set the stage for an even more high-profile contest in 2018 between a Republican incumbent and Anita Earls, a veteran voting rights champion who led local Democrat’s crusades against GOP-drawn maps determined by federal courts to be racial and partisan gerrymanders.

Republican lawmakers pulled out all the stops to defeat Earls. They mulled packing the courts to protect them from challenges to their gerrymanders. They passed legislation to make state Supreme Court races partisan again, explicitly acknowledging that GOP candidates would likely benefit. They tried to undermine a Republican challenger to the incumbent who they feared would split conservatives’ vote—a prediction that ultimately came true.

Earls won the race handily, giving Democrats a 5-2 majority that they will hold until at least 2022, well after the initial maps have been drawn.

Elections experts cautioned that redistricting isn’t the only focus in these races. Party operatives often get voters’ attention by running attack ads on issues that rarely come before these courts at all, like criminal justice and immigration. Citizens United opened the door to a flood of spending in judicial races by interest groups outside the state, as the Brennan Center has documented.

“The groups that are spending in state Supreme Court elections are very sophisticated political spenders,” the Center’s Keith said. “There are particular issues that they are interested in and that they believe the outcome of this race will affect, whether it’s redistricting in one state or reproductive rights in another or tort reform in another.”

State Supreme Courts are also set up differently depending on the state. Of the 38 that use elections to select these judges, 16 allow governors to appoint the judges. They then face “retention elections” where voters give incumbents a yes or no vote. Only 15 hold contested, ostensibly nonpartisan elections. While all judges are supposed to be impartial, candidates’ party affiliations are seen as a signal of how they’ll rule on sensitive political topics.

“It’s just become an extension of partisan warfare,” University of Florida elections expert Michael McDonald told TPM.

In states like Wisconsin, the focus on redistricting is explicit. Badger State Republicans’ 2011 gerrymander is considered one of the country’s most egregious; a lawsuit over the state legislative lines is still pending before the U.S. Supreme Court.

The Walker-affiliated National Republican Redistricting Trust is leading the charge for Hagedorn’s election, with Walker tweeting Monday about a sinister “master plan to gerrymander Democrats into long-term power.” The RSLC’s “Judicial Fairness Initiative” is spending $1.1 million on digital, mail, broadcast, cable and radio ads in the state.

The National Redistricting Action Fund, the 501(c)(4) affiliate of Holder’s redistricting group, has committed $350,000 for advertising and organizing efforts on Neubauer’s behalf.

Tuesday’s race in Wisconsin is seen as the precursor to another state Supreme Court election next year, which will determine the body’s partisan tilt. A Neubauer win means the court retains its current 4-3 conservative majority. That gives Democrats a shot to earn the majority in 2020, when the race is scheduled to fall on the day of the state’s Democratic presidential primaries. A Hagedorn win means consolidated conservative control of the court ahead of 2021 redistricting.

Daniel Tokaji, a redistricting expert at Ohio State University, expressed mixed feelings about all the talk of gerrymandering in the Wisconsin race.

“In my view, it’s a great thing that state Supreme Courts have become more receptive to claims of extreme partisan gerrymandering,” Tokaji said, calling them “more tuned into the issue than was the case a decade ago.”

But these costly, bitter races harm public confidence in judicial independence—and, research shows, affect how judges ultimately rule on the bench.

“It’s expecting a lot to think that judges who are elected as nominees of a major party will be completely neutral about these cases,” Tokaji said.