Slate’s expanded voting rights coverage is made possible by the support of Slate Plus members and readers like you.

It has never been clear whether Kris Kobach understands what his job is. As Kansas’ secretary of state, a position he’s held for nearly eight years, Kobach’s main responsibility is to serve as the state’s chief elections officer. But instead of ensuring that Kansas’ elections run smoothly, Kobach has used his office to foment nativist hysteria around the nonexistent problem of voter fraud, attempting to purge and prosecute voters while tormenting immigrants. This campaign raised his national profile and lined his pockets with taxpayer money. But it did not improve Kansas’ elections system, which Kobach allowed to atrophy despite mounting evidence that future races could be thrown into chaos.

Now that chaos has arrived, in the very election that will determine Kobach’s political future. The Aug. 7 primary between the secretary of state and incumbent Republican Gov. Jeff Colyer remains too close to call due to Election Day errors that left thousands of ballots in limbo. Kobach’s lead of 110 votes could disappear depending on if (and how) these votes are counted, decisions the secretary of state may be able to affect despite having ostensibly recused himself from the process. The whole mess is an absolute nightmare for Kansas Republicans, one they richly deserve. For years, the state GOP allowed Kobach to abuse the powers of his office for political gain while failing to perform basic duties. Now his negligence has come back to haunt the party, which faces an internecine brawl that is spiraling toward catastrophe.

When Kobach ran for secretary of state in 2010, he coasted to office promising to pass a slew of voter-suppression measures—measures he deemed necessary to counteract the fake scourge of dead people casting ballots. At Kobach’s urging, the GOP-dominated Legislature passed a law in 2011 requiring individuals to provide proof of citizenship when registering to vote. Republican Gov. Sam Brownback signed the bill despite there being serious doubts over its legality. Kobach also urged the Legislature to grant him authority to prosecute voter fraud, which it did over unanimous Democratic opposition.

The bungled 2016 Kansas election was a model of proficiency by comparison to last week’s calamity.

Although Kobach claimed to have identified 100 cases of possible double voting, he has only secured a handful of convictions—mostly confused seniors, not nefarious immigrants. His work did catch the eye of Donald Trump, who put him in charge of the presidential voter-fraud commission. But the panel collapsed after Kobach illegally iced out one Democratic commissioner, spurring a lawsuit. And in June, a federal judge permanently blocked Kobach’s signature proof-of-citizenship law when he could not provide any evidence of voter fraud in court. (Kobach defended the measure himself and performed so badly at trial that the judge ordered him to attend continuing legal-education classes.)

Meanwhile, as ProPublica and the Kansas City Star recently reported, Kobach moonlighted in courts across the country defending anti-immigrant ordinances he drafted and championed. He identified small, majority-white towns experiencing influxes of nonwhite immigrants and encouraged them to drive out these newcomers by excluding them from housing and employment. When his ordinances were challenged in court, Kobach defended them at a steep price, earning $800,000 in total and at least $150,000 while in office. One town required a state bailout to pay for his services; another had to raise property taxes. Not a single Kobach-authored ordinance is in effect today.

As Kobach pursued these pet causes, it quickly became obvious that he wasn’t performing the job he’d been elected to do. The secretary of state devoted remarkably little time and energy to registering voters, supervising election officials, or upgrading election technology. Instead, he delegated key tasks to subordinates and allowed county-level election commissions to run as semi-autonomous fiefdoms. When Kobach failed to follow a court order blocking his proof-of-citizenship law, he threw these commissions under the bus, insisting he could not make them follow his instructions. (The judge rejected this absurd claim.)

Kobach’s neglect had dire consequences for Kansas elections. When the legislature changed the date of school-board elections in 2015, it directed Kobach to educate voters about the shift. He did not, and turnout plummeted. In 2016, a botched vote tabulation in Johnson County, the state’s largest county, created a substantial delay in election results. Johnson County Election Commissioner Ronnie Metsker, the official in charge of the process, was appointed by Kobach, who did nothing to prepare the state for a pre-election surge in voter registrations. (At that point, he was already busy defending his proof-of-citizenship measure.)

But the bungled 2016 Kansas election was a model of proficiency by comparison to last week’s calamity. Once again, Kobach and Metsker failed to predict a substantial turnout, leading to lengthy lines and an all-night delay in results. The county’s new voting machines—purchased this summer at a cost of $10.5 million—also suffered glitches.

“I’m embarrassed for our county,” Metsker told the Kansas City Star. “It’s embarrassing for our office, it’s embarrassing for me, for our team and for the vendor.”

Kobach should be embarrassed too. It’s no surprise that Kansans were enthusiastic about the 2018 primary, yet his office did startlingly little to help county commissions prepare for an influx of voters. And while his appointee Metsker has now overseen two consecutive elections that were universally regarded as humiliating administrative disasters, Kobach has totally dissociated himself from the mayhem in Johnson County.

Equally disturbing was Kobach’s initial refusal to recuse himself from the vote-tabulation process on the grounds that he would not “participate directly in the recount.” (He would still have influence over the acceptance or rejection of challenged ballots.) Kobach partially reversed himself after his office mysteriously subtracted 100 votes from Colyer and allegedly gave inaccurate guidance to county officials. But he handed over duties to his hand-picked deputy, Eric Rucker, a move that Colyer asserts does not resolve Kobach’s conflict of interest.

By Monday, the fight between Kobach and Colyer focused on the question of provisional ballots. Poll workers are supposed to give these ballots to voters who cannot verify their identities on-site. On Aug. 7, however, some officials reportedly gave provisional ballots to voters who could verify their identities and were trying to declare a political party. Kansas law lets unaffiliated voters register with a party at the polls, then cast regular ballots. It appears that a number of poll workers misunderstood this rule and instead forced unaffiliated voters to cast provisional ballots. (This problem might have been avoided had Kobach’s office provided clear guidance on the issue.)

Naturally, a skirmish broke out between Kobach and Colyer over whether these ballots should count. Rucker, the Kobach deputy, told officials not to count the provisional ballots of unaffiliated voters who didn’t register with a party. Colyer’s attorney argued that, to the contrary, officials should count all unaffiliated voters’ provisional ballots, construing them as “evidence of voter intent.” Metsker sided with the secretary of state’s office, agreeing to count only those provisional ballots that were accompanied by party registration.

That decision is a tough break for Colyer, who seems to think that unaffiliated voters might lean away from his reactionary opponent. But Colyer is squaring off against a political machine that he helped to create. Kobach and his many loyal deputies amassed power with the near-total acquiescence of the Kansas Republican establishment. Colyer—who served as lieutenant governor for seven years before assuming the governorship in January—did not see fit to criticize Kobach until he ran against him. He now describes Kobach as a tendentious bomb thrower who could lose the November election to a Democrat. But it’s extremely difficult to take these accusations seriously when Colyer, a major player in state politics, appeared to embrace Kobach for years.

Republican legislators too are beginning to voice concerns over the increasingly nasty battle. (It’s worth noting that Colyer has remained fairly civil, while Kobach has bitterly accused his opponent of undermining faith in the election.) Lawmakers held a “unity breakfast” in the hopes of putting this “intramural scrimmage” behind them. (Democrats are overjoyed by the clash.) On the campaign trail, Kobach repeatedly promised to “drain the swamp” in Topeka, alleging that the state capital has a “culture of corruption.” Because Republicans have a stranglehold on the legislature, his insults seemed to be aimed at GOP lawmakers—many of whom voted to give him unprecedented prosecutorial powers just a few years ago.

Colyer and other anxious Republicans are now facing the same hardball tactics that Kobach used against immigrants and voters for years. And they are suffering the consequences of a dilapidated electoral system that withered as the secretary of state ignored his day job to gain fame and money elsewhere. Had Kansas Republicans revolted against Kobach early in his tenure, they might have halted his ascent. Now they have discovered it is far too late to rein in the man whose rise to power they abetted at every turn.