Media playback is unsupported on your device Media caption Roy Moore: 'Sexual perversion and sodomy sweep this land'

Alabama firebrand Roy Moore dealt a huge blow to the Republican leadership by winning the party's nomination for the Senate, despite their backing for his opponent.

He is now battling Democrat Doug Jones for a place in the upper chamber of Congress.

The controversial lawyer has made headlines for a series of incendiary remarks over the years.

Here's a round-up of some of his more extreme beliefs, with some analysis from the BBC's Anthony Zurcher on why it all matters.

1. Homosexuality should be illegal

On election day, Moore's spokesman Ted Crockett was asked whether the candidate still thought homosexuality should be outlawed. "Probably," was his answer. Previously, Mr Moore has likened it to bestiality, and called it "abhorrent, immoral, detestable, a crime against nature, and a violation of the laws of nature and of nature's God upon which this nation and our laws are predicated". His refusal to issue marriage certificates to gay couples cost him his place on the bench for a second time.

2. God's wrath is felt on Earth

Moore has suggested that the 11 September 2001 attacks against the World Trade Center and the Pentagon were a sign of God's divine anger. "Sounds a little bit like the Pentagon" he remarked after reading a Bible passage about "the great slaughter when the towers will fall". He has also said that violent crimes in the US such as murder and rape are "happening because we have forgotten God".

3. 'Red and yellows' don't get along

He appeared to use pejorative racial terms for Asians and Native Americans at a rally this month."We have blacks and whites fighting, reds and yellows fighting, Democrats and Republicans fighting, men and women fighting. What's going to unite us? What's going to bring us back together? A president? A Congress? No. It's going to be God."

4. Darwin was wrong

"There's no such thing as evolution," he told the Washington Post less than a week before the election. "That we came from a snake? No I don't believe that."

5. Islam is a 'false religion'

It is also a threat to US laws, Moore claims. Over the summer he falsely alleged that Sharia law was already being enforced in parts of the states of Illinois and Indiana, offering no evidence.

6. The law comes from God

"God is the only source of our law, liberty and government," he said from the debate stage last week.

7. He thinks he's like Putin

In August he directly praised the Russian president Vladimir Putin for his gay rights stance, saying "maybe he's more akin to me than I know". The comment came after he described the US as "the focus of evil in the world" because "we promote a lot of bad things".

8. Obama might not be US-born

Trump's predecessor was disqualified to be president, Moore claimed as far back as 2008. The so-called "birther" theory, alleging that Obama was born in Kenya, was heavily promoted by Donald Trump until very late in his campaign.

9. He writes poetry

And he has occasionally been known to give live renditions. One said: "Babies piled in dumpsters, Abortion on demand/ Oh Sweet land of liberty; your house is on the sand."

10. A Ten Commandments sculpture is worth fighting for

He was dismissed from the Alabama Supreme Court after he refused a federal order to remove a massive stone statue of the Ten Commandments from inside his courthouse.

How his views helped him win

Roy Moore's willingness to buck the establishment, offer full-throated support for often-controversial evangelical issues and even defy federal court orders won him a loyal following in the heart of the Bible belt.

Some of his views are extreme - offensive, even, to many Americans - but as with Donald Trump, the ex-judge's willingness to unapologetically speak his mind helped make him a vessel for frustrated Alabama voters looking to send a message to a Washington establishment they view as still firmly in control.

Mr Moore's opponent, Luther Strange, was also flawed - an uninspiring candidate appointed to his Senate perch by a scandal-plagued governor. The national Republican Party poured money into the race to boost Mr Strange, but the appearance that the senator was the pick of political insiders probably did more harm than good.

Motivated supporters willing to vote in droves in a low-turnout special primary is certainly a top reason why Mr Moore is now one step away from being Alabama's next US senator. Who Mr Moore isn't - a Washington insider, a typical politician, Luther Strange - helped a lot, as well.

Anthony Zurcher, BBC News, Washington - follow @awzurcher