Roy Moore of Alabama has been twice elected to lead his state’s supreme court and twice thrown out of that position. The first time, in 2003, he refused to obey a federal court’s order to remove a monument of the Ten Commandments from the courthouse in Montgomery. The voters of Alabama restored him, and in 2016, he was thrown off the bench again for refusing to implement the Supreme Court’s decision legalizing gay marriage.

On Tuesday, a plurality of Alabama Republican voters picked Moore to be their candidate for U.S. Senate. With 99 percent of precincts reporting early Wednesday morning, Moore had 39 percent of the vote to 33 percent for the incumbent, Luther Strange, and 20 percent for Representative Mo Brooks. Moore and Strange will now advance to a runoff election for the Republican nomination next month. The winner will proceed to a general election against the winner of Tuesday’s Democratic primary, former federal prosecutor Doug Jones.

The first-place finish for the colorful Moore might not have even been the most remarkable aspect of the Republican primary, which played out as a fascinating allegory of the GOP’s new fault lines in the uncharted territory of the Trump era.

The special election is being held because the Senate seat’s former occupant, Jeff Sessions, was appointed attorney general by President Trump. In February, the Republican governor, Robert Bentley, appointed Strange to fill the vacancy. The fact that Strange was, at the time, the state attorney general overseeing a criminal investigation of the very same same scandal-tarred governor who had given him his ticket to Washington made many Alabamans smell a rat. Despite the specter of a quid pro quo in the style of the former Illinois governor Rod Blagojevich, nothing was ever proven; Bentley subsequently resigned.

The Senate majority leader, Mitch McConnell, made it a major priority to keep Strange—a former Washington lobbyist and reliable Republican vote—in the Senate. But two anti-establishment troublemakers entered the race against him. Moore, a stalwart of the local and national religious right, and a known quantity to Alabama voters, was one; Brooks, an archconservative member of the House Freedom Caucus who had chaired Ted Cruz’s Alabama campaign, was another.

Moore has his own brand in Alabama independent of the politics of the moment, a devoted band of followers who can be counted on to vote in GOP primaries. Local experts like to say he had a “high floor but a low ceiling”: Even in a primary, he would have a hard time broadening his appeal beyond his built-in base.

Brooks had the support of national conservatives like Sean Hannity and Mark Levin, but wasn’t well known outside his North Alabama congressional district. He sought to turn the race into a referendum on the Washington GOP establishment, particularly McConnell—one of his final campaign events was a “Ditch Mitch” rally Monday night. But his ambivalent relationship with the president, whom he had criticized in the past, didn’t play well with Trump-loving Alabama Republican primary voters.

Brooks’s onetime antipathy for Trump was a major theme of the multimillion-dollar barrage of attack ads aired by Strange and his allies. (A source who polled the race told me Trump is viewed favorably by 68 percent of Alabama Republicans.) But the killing blow came a week before the election, when Trump unexpectedly endorsed Strange on Twitter—the first time the president has waded into a contested GOP primary. Trump apparently did it as a favor to McConnell—but then went after McConnell when he learned the majority leader had been patronizing him behind his back. Still, the president stuck with Strange, issuing more tweets and a recorded message in favor of the incumbent.

Trump’s popularity likely helped drag Strange across the finish line in second place. But it’s notable that his endorsement was only good enough for second place, and less than a third of the primary vote, for his favored candidate. Now Strange faces Moore one-on-one for the nomination, with Moore positioned as the outsider and Strange as the Washington candidate tainted by corruption.

McConnell’s allies have indicated that they intend to go hard against Moore, whose Bible-thumping ways do give many Alabamans pause—one Brooks voter I met told me it was hard enough telling out-of-staters you’re from Alabama without Moore underscoring outsiders’ stereotypes. “Here’s the question, what happens when McConnell & Co. train their guns on Moore?” asked David Mowery, a Montgomery-based consultant who ran a Democratic campaign against Moore that nearly succeeded in 2012. “He is very, very hard to attack,” because of his reputation for standing on principle.

The Republican voters I met in Alabama had interesting perspectives on the embattled president. Nearly all supported Trump, but they were frequently vexed by his actions, and they were all offended when he hung Sessions out to dry a few weeks ago. Several said they supported Trump’s agenda but not necessarily his behavior—more than one blamed his boorishness on his being a Yankee.

But the most important thing I learned was that these red-state voters, accurately perceiving the paralysis and dysfunction in Washington, didn’t hold Trump responsible for it. They blamed Republican leaders like McConnell and House Speaker Paul Ryan; they blamed the “swamp”; they blamed the establishment elements in Trump’s own orbit for getting in his way.

They said they wanted a senator who would exert leadership to get things done. But they saw a president who was already doing all he could.