 -- Former Alabama Chief Justice Roy Moore defeated Sen. Luther Strange in the state's Senate Republican primary runoff election Tuesday, delivering a blow to President Donald Trump and Senate Majority Leader Mitch McConnell, who backed the incumbent.

Moore advances to face Democratic nominee and former U.S. Attorney Doug Jones in the general election on Dec. 12.

The special election primary gained national prominence because of what was at stake: the political sway of Trump's administration versus the base that helped him win the White House.

In his speech, Moore acknowledged Trump's endorsement of Strange but said he was still fully supportive of the president and his agenda.

"Don't let anybody in the press say that because [Trump] supported my opponent, I do not support him," Moore urged a crowd of cheering supporters at the RCA Activity Center in Montgomery.

Trump put time into the Strange campaign, holding a rally for the senator — who was appointed in February to the seat vacated by Jeff Sessions when he became attorney general — last week in Huntsville, where Trump admitted he "might have made a mistake" in backing the incumbent and pledged to back Moore should he win.

Strange also had the backing of McConnell, and the Senate Leadership Fund pumped $7 million into the race. In the past week Trump and Vice President Mike Pence traveled to Alabama to stump with Strange.

Moore is a well-known but controversial figure in the state who was twice removed as a jurist from the Alabama Supreme Court. In 2003 he defied an order to remove a Ten Commandments monument from a state courthouse, and in 2016 he ordered state probate judges not to issue marriage licenses to same-sex couples, in defiance of a U.S. Supreme Court ruling.

Trump congratulated Moore in a tweet just as the former jurist took to the stage at his election night party to deliver a victory speech. The president's message mistakenly encouraged Moore to win in November, a month before the general election, though Trump later replaced the post with a tweet correcting the month to December.

Moore told reporters that Trump called after his victory but that he was in a crowd and did not hear his cellphone. He said he also spoke with Sens. Mike Lee, Rand Paul and Ted Cruz, three members of the chamber most ideologically aligned with Moore.

He later tweeted he had a chance to speak with Trump on the phone and shared a photo on Twitter.

The former judge received the support of former White House aides Steve Bannon and Sebastian Gorka, former Alaska Gov. Sarah Palin, actor Chuck Norris and "Duck Dynasty" star Phil Robertson.

After his win, Moore tweeted, "CONSERVATIVE VICTORY HAS COME TO #ALSEN! Because of you, tonight, the establishment has been DEFEATED in Alabama! THANK YOU!"

While Moore supporters at the Montgomery rally said they fully supported Trump, several said they also wished he had simply not picked a side in the primary.

"He should have never gotten in the middle of it," said Win Johnson of Montgomery.

Despite an undercurrent of frustration with Trump for picking sides, Bannon and other Moore endorsers sought to present a united front, channeling Trump's message at events.

At a Moore campaign rally Monday night, Bannon paraphrased William Shakespeare's funeral oration by Mark Antony for Julius Caesar, saying, "We did not come here to defy Donald Trump. We came here to praise and honor him."

Sessions held the Senate seat for 20 years before joining the Trump administration.

In February, Alabama's then-Gov. Robert Bentley appointed Strange, the state's attorney general at the time, to fill the Senate seat until the next general election, in 2018. After Bentley's resignation because of a political scandal, then–Lt. Gov. Kay Ivey became governor and in April called for a special election.

Strange was dogged by accusations that he accepted a quid pro quo arrangement, because he asked state lawmakers in November to suspend their impeachment investigation into Bentley so that his office could conduct "related work."

Known as "Big Luther" — at 6 foot 9, he is the tallest senator in U.S. history — Strange has also faced attacks for his work as a lobbyist for Sonat Offshore, an influential gas utility, and as a corporate lawyer in Birmingham.

In a statement congratulating Moore on Tuesday night, Strange wrote that he "will go back to work with President Trump and do all I can to advance his agenda over the next few weeks." He added that he was "especially grateful for the support of President Trump and Vice President Pence, as well as the strong example set by my friends [Sen.] Richard Shelby and Jeff Sessions."

Before his run for Senate, Moore was a controversial figure, displaying a wooden carving of the Ten Commandments in his courtroom in the 1990s when he served as a circuit court judge. After he was elected Alabama's chief justice, Moore refused to remove a marble monument of the Ten Commandments that he installed outside the state Supreme Court in 2001, leading to his removal from office in 2003.

He was re-elected chief justice in November 2012 but was suspended in May 2016 after ordering state probate judges to ignore the U.S. Supreme Court's June 2015 ruling that legalized same-sex marriage nationwide. He resigned in April of this year.

The first primary election was on Aug. 15. None of the nine Republican candidates garnered over 50 percent of the vote, triggering a runoff. Moore and Strange were the two top candidates; Moore won 38.9 percent of the vote, and Strange garnered 32.8 percent.