Donald Trump has suffered a major political humiliation as the man he backed in a Republican race in Alabama lost to a challenger from the far-right and evangelical wing of the party who had the support of the former top strategist to the President and populist firebrand, Steven Bannon.
After a six-week campaign during which Roy Moore and his supporters pitched him as a true insurgent - a genuine anti-establishment before Mr Trump picked up the cause - the 70-year-old former judge was declared winner in the contest to select a Republican candidate for the US Senate seat left vacant by Jeff Sessions, after he was tapped to join Mr Trump's cabinet as Attorney General.
Mr Moore defeated Luther Strange, despite Mr Strange having received the backing of Mr Trump, Vice President Mike Pence and many leading figures of the Republican establishment who poured millions of dollars into his campaign.
Appearing at a victory party on Tuesday evening after the race was called, Mr Moore underscored the religious conservatism that he will take with him to Washington.
"There’s one person you don’t see on this stage that’s done more for my campaign than anybody, and that's almighty God,” he said. "There is so much division in our society but we are all created in the image of God.”
The result represents a dangerous challenge to the Republican Party leadership in Washington of Mitch McConnell and Paul Ryan, of the Senate and House respectively, because it will be seen as a fresh rebuke to the party establishment by Republican voters in the southern state.
It will also highlight criticism from some on the right, including Sarah Palin, the former Governor of Alaska, who campaigned for Mr Moore, that Mr Trump has fallen under the spell of the old-guard Republican establishment in Washington DC
Indeed, many of Mr Moore’s supporters voiced disappointment that Mr Trump had endorsed Mr Strange, a state prosecutor who had been appointed to fill the seat on a temporary basis by the then governor who was being investigated for ethics abuses. The governor later resigned.
A numnber said Mr Trump should have either endorsed Mr Moore, or else kept out of matters entirely and left it up to the voters of Alabama.
Mr Trump may have recognised his error, for when he appeared at a rally for Mr Strange last week in Huntsville, he voiced aloud that he should have perhaps got behind Moore. As it was, it was Mr Bannon, the street-fighting populist now back at the helm of the conservative Breitbart News, who helped steer and push Mr Moore’s candidacy - the first of many anti-establishment Republicans he intends to endorse and support in the 2018 midterms.
Mr Bannon had delivered a strident, rousing speech at an election eve rally for Mr Moore near Mobile, and he appeared briefly at the victory party on Tuesday night in Montgomery, the state capital.
Mr Bannon declared Mr Moore's win a victory for the President, and Mr Moore said he supported Mr Trump, despite the President's support for Strange.
After the race, Mr Trump tweeted his congratulations to the man who defeated his preferred candidate. "Congratulations to Roy Moore on his Republican Primary win in Alabama. Luther Strange started way back & ran a good race. Roy, WIN in Dec," he said.
Mr Moore has embraced controversy throughout much of his career. Twice, he lost his position as the most senior judge in the state, once for his insistence of installing a vast granite statue bearing the Ten Commandments into the grounds of his courthouse, and a second time after telling Alabama judges they could ignore a Supreme Court ruling that legalised same-sex marriage.
More recently he suggested the attacks of 9/11 may have been a punishment for the country’s decision to turn its back on God.
Alabama is a strongly conservative state. The last Democratic president to win here was Jimmy Carter in 1976. Mr Trump beat Hillary Clinton 62-34 in the 2016 presidential contest.
As such, Mr Moore is strongly tipped to defeat his Democratic challenger, Doug Jones, in the general election for the Senate seat in December.
At the victory party, person after person spoke of the importance to them of Mr Moore’s strong religious beliefs.
"God is who is he is. He wants to shepherd us. He wants people to represent us in all walks of life, including politics, who honour him, who know him and obey him,” said one supporter, who asked to be identified as Kathy.
Susan Crawford, one of the few people of colour at the event, said she had voted for Mr Moore because he spoke his mind - similar to Mr Trump, who she voted for last year. "I think America has got what we need,” said Ms Crawford, a entrepreneur and minister.
Mr Strange, 64, who had campaigned with Vice President Mike Pence on Monday night and who was the recipient of $9m poured into his funds by Republicans in Washington, spoke to his supporters at a rally in Birmingham, saying: "We wish [Moore] well going forward.”
In an insight to the situation many mainstream Republicans may face in 2018 in the light of Mr Moore’s victory, he added: "We’re dealing with a political environment that I’ve never had any experience with.”