BIRMINGHAM, Ala. — Roy Moore wouldn’t stand a chance in many Senate races after defying federal court orders, describing Islam as a false religion, calling homosexuality evil and pulling out a revolver on stage before hundreds of supporters.

But in Alabama, he’s now the odds-on favorite to join the nation’s most exclusive political body. Moore prevailed Tuesday in a Republican primary runoff by defeating an opponent backed by both President Trump and deep-pocketed allies of Sen. Mitch McConnell.

As hard as it may be to understand in New York or San Francisco, Moore is widely popular across a mostly white, Christian-dominated state where voters have repeatedly embraced outsiders who campaign on embracing God and rebuffing authority.

“The things that end careers for politicians elsewhere strengthen Roy Moore,” said Alabama political strategist David Mowery, who helped run a Democratic campaign against Moore for state chief justice in 2012.

After all, this is a state where George C. Wallace, who famously vowed “segregation forever” and defied court orders, won four terms as governor. President Trump carried the state. It’s a place where campaign commercials often depict politicians at a church, praying or holding a Bible.

Moore wraps all that into a single package. He was removed as chief justice of the Alabama Supreme Court twice after higher courts found he rejected rulings regarding Ten Commandments displays and gay marriage. He’s also a horse-riding, gun-toting Vietnam veteran who has talked for his entire public career about acknowledging the God of the Christian Bible.

He lost bids for the Republican nomination for governor in 2006 and 2010, but that didn’t matter in the Senate race.

In his closing argument to voters – an election eve appearance where he stood in a barn and brandished a handgun to demonstrate his support of the Second Amendment – Moore quoted both scripture and the state’s motto: “We dare defend our rights.”

Alabama is Trump country, but the fact that Trump endorsed incumbent Sen. Luther Strange didn’t bother most voters one bit. They still went with Moore.

Bill Armistead, Moore’s campaign chairman and a former chairman of the Alabama Republican Party, said Alabamans have known Moore a lot longer than they have known Trump.

“They have an opinion of Roy Moore, and they believe he is the kind of man that will go up and fight for them,” Armistead said.

Starting in the mid-1990s, Moore rose to prominence while working as a circuit judge in Etowah County, where he drew challenges from the American Civil Liberties Union for opening court with a prayer and hanging a handmade Ten Commandments plaque on the courtroom wall. He was later twice elected Alabama chief justice.

Before the election, Republican political consultant David Azbell said years of fighting for the Ten Commandments had made Moore unusually popular in Alabama.

“The perception is that Moses has endorsed Roy Moore,” Azbell said.

His supporters flooded Tuesday’s special Republican runoff for the Senate seat once held by Attorney General Jeff Sessions, giving him a 9-point victory over Strange, who was a lobbyist before he was elected Alabama attorney general and then appointed to fill the remainder of Sessions’ term.

Now Moore must turn his attention to Democratic nominee Doug Jones, an attorney best known for prosecuting the final two Ku Klux Klansmen convicted of setting the bomb that killed four black girls at Birmingham’s 16th Street Baptist Church in 1963.

Jones said he intends to concentrate on jobs, health care and the economy.

“After years of embarrassing headlines about top public officials in this state, this race is about the people of Alabama and about choosing a candidate with character and integrity,” he said in a statement.

At a victory party in Montgomery that included hymns and a lengthy prayer, Moore showed he doesn’t plan to veer from the formula that brought him this far.

“We have to return the knowledge of God and the Constitution of the United States to the United States Congress,” Moore told a cheering crowd.