EVEN if Donald Trump had not become president, Senator Jeff Flake of Arizona would probably still be facing a challenge in the Republican Senate primary in 2018. Grassroots conservatives in Arizona have long distrusted him for his perceived apostasy, especially his support for immigration reform. But Mr Trump is the president, and Mr Flake has cast himself as a voice of intraparty opposition to him, transforming his bid for a second term into a battle for the soul of the Republican Party.

Alabama provides a glimpse of what may be in store. On September 26th, Roy Moore, a populist conservative jurist, defeated Senator Luther Strange, the incumbent, in the state’s Republican primary. Though Mr Strange had the support of the president, it was Mr Moore who carried the banner for those who want to “drain the swamp,” as Mr Trump is fond of saying. Mr Strange’s defeat was a loss for the establishment, and political prognosticators now look to other states, Arizona included, to see if the far-right rebellion will spread.

Mr Flake did not endorse or support Mr Trump in 2016, even after he won the Republican nomination. This year, he ratcheted up his opposition, writing “Conscience of a Conservative,” a book that excoriated Mr Trump and his effect on the Republican Party. Mr Trump has taken notice, and wants Mr Flake ousted.

Kelli Ward, an osteopathic physician and former state senator, hopes to be the candidate who helps the president with that. Mrs Ward unsuccessfully challenged John McCain, Arizona’s other senator, in 2016, and now seeks to unseat Mr Flake. She has made Mr Flake’s animosity toward the president a cornerstone of her campaign, and hailed Mr Moore’s win in Alabama as evidence that voters want senators who will help Mr Trump advance his “America First” agenda. On October 17th, Steve Bannon, who has said that he is “declaring war on the Republican establishment” appeared alongside Mrs Ward at a campaign event. "It's an open revolt and it should be," he told that gathering. "These people hold you in total contempt".

Mrs Ward has at times struggled to convince voters that she’s a serious candidate. As a state senator, she asked Arizona’s environmental regulation agency to convene a meeting so constituents could voice their concerns about “chemtrails”. Though she says she doesn’t subscribe to the conspiracy theory herself, her foes deride her as “Chemtrail Kelli.” More recently, Mrs Ward stuck her foot in her mouth by urging Mr McCain to resign following his disclosure that he’d been diagnosed with brain cancer, and said she hoped that Doug Ducey, Arizona’s governor, would appoint her as his replacement if he stepped down.

Concerns among some Republicans that Mrs Ward’s brand of ultraconservative politics may turn off voters in the general election in November 2018 has intensified with the recently announced candidacy of Kyrsten Sinema, a Democratic fundraising dynamo with a strong centrist record. She presents a rare opportunity for her party to win one of Arizona’s Senate seats for the first time since 1988.

For the Republican primary in August the wind currently seems to be at Mrs Ward’s back. Several polls show her leading Mr Flake by double digits. Robert Mercer, a Republican mega-donor and big Trump supporter, gave $300,000 to a pro-Ward super PAC. Mrs Ward has added veterans of the pro-Trump Great America PAC to her campaign team. Mr Trump has tweeted that it’s “Great to see that Dr. Kelli Ward is running against Flake Jeff Flake, who is WEAK on borders, crime and a non-factor in Senate.” Eric Beach, a recent addition to Mrs Ward’s team, says Mrs Ward has “professionalised” her campaign and is a more polished candidate than the one who lost to Mr McCain last year. “[Mr Trump] is more in line with where the American people are, and so is Kelli Ward,” Mr Beach says. “The base is a lot bigger than people think.”

Mrs Ward’s detractors note that while Mr Trump has tweeted praise for Mrs Ward he hasn’t actually endorsed her yet. Ryan O’Daniel, who ran Mr McCain’s 2016 campaign, said the White House was searching for a more “viable” candidate. “President Trump tweeted about her and then was meeting with other prospective candidates backstage at his rally two days later,” he says.

Among possible new challengers are Arizona’s state treasurer, Jeff DeWit, and Robert Graham, the former chairman of the Arizona Republican Party. Scepticism has been growing in Republican circles that either will run. But Mr Graham says things have changed since Mr Moore’s victory in Alabama. Since then, supporters have been calling, and he is looking anew at a race that he’d been leaning against. He says he will decide within weeks whether he will run.

Meanwhile Jay Heiler, a longtime Republican politico and member of the Arizona Board of Regents, an ally of Mr Trump, is wondering whether to join the race. Mr Heiler has the backing of Jan Brewer, a former governor and an ally of Mr Trump who has been making phone calls to whip up support for a possible candidacy.