In 2016, Democrat Mike Morgan won a hotly contested seat on North Carolina’s state Supreme Court, flipping the court to a 4–3 liberal majority. Ever since, Republicans in the state have engaged in a great deal of chicanery to prevent Democrats from winning another seat in 2018. For a while, they appeared destined to succeed. But a last-minute twist may thwart their carefully laid plans, allowing yet another progressive Democrat to flip a Republican-held seat in the November election.

The North Carolina Supreme Court plays a major role in the state’s politics due largely to the sharp split between the governor and legislature. Republicans hold a super-majority in the North Carolina General Assembly thanks to a racial gerrymandering that has been ruled illegal, while Democrat Roy Cooper serves as governor. Since Cooper won in 2016, Republicans have passed a series of laws stripping his office of power and entrenching GOP rule. (Cooper has attempted to block these extreme measures, but the legislature can easily override his veto.) The state Supreme Court, however, has managed to strike down Republicans’ more egregious power-grabs by consistent 4–3 votes, ruling that they violate the state constitution.

These rulings pit the court’s Democratic majority against its Republican minority. And North Carolina Republicans are convinced that Democrats’ majority is an accident: When Morgan ran in 2016, the party affiliation of state Supreme Court candidates did not appear on the ballot. But Morgan’s name was listed first, due to a random drawing by the state Board of Elections. After he won, toppling the incumbent GOP candidate, Republicans became convinced that he only triumphed because his name was listed first, and included no partisan affiliation. They speculated that many voters assumed he was a Republican, since Republicans were listed first in other races.

In response, the GOP’s legislative supermajority fundamentally altered the mechanism by which state Supreme Court candidates are nominated, eager not to repeat this ostensible mistake in 2018. First, they added partisan markers to the state Supreme Court ballot so no Republicans would accidentally vote for a Democrat. Second, they abolished judicial primaries for both parties on the theory that a free-for-all in the general election would benefit Barbara Jackson, the Republican incumbent up for reelection in 2018. Jackson, Republicans assumed, would draw no GOP challengers, while Democrats would compete against each other for the spot, canceling out Democratic votes.

Third, Republicans ensured that, this time around, the Democratic state Supreme Court candidate, Anita Earls, would appear last on the ballot. Here’s how: In February, Republicans hatched a plan after a state agency held a random drawing to determine the order of candidates in legislative primaries. It selected the letter “F”—meaning that candidates whose last names began with that letter would be listed first. Then came G–Z, and finally, A–E.

Under pending legislation, the agency would have held another drawing for the general election. But legislators quietly rewrote the bill and applied the primary rules to the general election ballot—including judicial candidates. Thus, candidates with a last name beginning in E would be listed last in the general election, too. The last-minute change was almost certainly designed to ensure that Earls, the Democratic candidate, will be listed last. This so-called “position bias” could detract from her vote total, and, in a close race, tip the election away from her.

Up to this point, the Republican scheme was going as planned. But in June, everything fell apart. Shortly before the registration deadline, a 32-year-old Raleigh attorney named Chris Anglin jumped into the state Supreme Court contest—as a Republican. Anglin was a registered Democrat until June 7, just before he entered the race. He insists that he is not a Democratic plant, instead declaring himself a “constitutional Republican” running to “stand up for the independence of the judiciary.” Anglin also implied that he was running to protest the GOP’s cancellation of judicial primaries, which he considered an assault on “the judiciary as a coequal branch of government.” He has hired a Democratic strategist, Perry Woods, to run his campaign.

North Carolina GOP executive director Dallas Woodhouse has already called Anglin “the enemy,” seemingly acknowledging that there is a very good chance he will siphon votes from Jackson, the Republican incumbent. (It certainly sounds like Anglin is, at the least, an irritated Democrat who decided to exploit Republicans’ manipulations for liberal gains.) If he does split the GOP vote, then Earls—an unapologetic progressive and civil rights attorney—will have an easier time winning the seat, giving Democrats a 5–2 majority on the state Supreme Court. And Republicans’ endless intrigue will have backfired.

There is, alas, still time before the November election for Republican legislators to pass another law targeting Earls—a new rule that no one named “Anita” may appear on the ballot would not be surprising given the GOP’s increasing lack of subtlety. But for now, it appears that Earls has a better shot than ever at winning. If Republicans hadn’t intervened, Jackson might have coasted to reelection on incumbency advantage alone. Now her seat is in serious jeopardy. And if she loses to Earls, Republicans will have only their own buffoonery to blame.