After winning Tuesday night's Alabama GOP Senate primary runoff, Roy Moore is one step closer to the United States Senate. The anti-establishment conservative could give Republican leaders plenty of headaches if he wins the general election in December.

The former chief justice of the Alabama Supreme Court, Moore has been in the public eye for almost two decades amid a number of controversies in that time, including his removal from the bench and a separate suspension. One thing he has never shied away from is his devout religious beliefs and the conviction that faith should be integrated into the public square and with the law.

Moore has to defeat Democrat Doug Jones, a former U.S. attorney, to get to the Capitol. Republican leadership has warned that a Moore victory in the primary would make securing what should be a safe seat more difficult for the party. President Trump and Senate Majority Leader Mitch McConnell backed Moore's primary opponent, Sen. Luther Strange.

Still, Moore remains the favorite in ruby red Alabama, and Democrats will have to decide whether wading into the contest is a worthwhile investment.

Here's a rundown of some of Moore's past judicial controversy and statewide bids:

"The Ten Commandments Judge"

Moore gained his nickname even before he was elected statewide, for refusing to take down a hand-carved plaque of the Ten Commandments hanging behind his bench when he was the Etowah County circuit court judge.

In 1995, the American Civil Liberties Union sued over the plaque and Moore's habit of opening sessions with prayers, saying such actions were unconstitutional and violated the separation of church and state.

"Separation of church and state never meant to separate God from government," Moore told NPR at the time. "The First Amendment never meant to divide our country from an acknowledgement of God. It's time to stand up and say, we have a right under our Constitution to acknowledge God."

The Montgomery Advertiser wrote in a recent profile of Moore that "the original lawsuit was dismissed due to lack of standing, but then-Gov. Fob James — who once pledged to send the National Guard to defend the plaque — sued to get a ruling on the constitutionality of Moore's actions. In 1996, Montgomery County Judge Charles Price initially ordered Moore to stop the prayer but allowed the Ten Commandments plaque to be displayed; however, he ordered the plaque removed after visiting Moore's courtroom the following year."

Eventually, though, the case was dismissed by the Alabama Supreme Court and the plaque got to stay, giving Moore a "new statewide status," according to the Advertiser.

When he was elected to the Alabama Supreme Court in 2000, Moore took his crusade over the Ten Commandments even further, designing and commissioning a 2 1/2-ton granite monument inscribed with the Ten Commandments to be placed in front of the court.

"Moore had not told his fellow justices he was planning to install the monument, but brought a company in to tape the installation of the monument in the Heflin-Torbert Judicial Building. Sales of the tapes later helped pay for his legal defense fund," the Advertiser says.

A federal lawsuit was filed over the monument, and in 2002, a federal district judge ruled it was unconstitutional, violating the establishment clause of the Constitution. A deadline for removing the monument came and went in August 2003, and Moore refused to budge. A state panel ruled that Moore had violated the judicial ethics code, and Moore was removed from the bench.

Moore, however, didn't have any regrets about standing by his beliefs.

"I will not violate my oath," he told NPR in 2003. "I cannot forsake my conscience. I will not neglect my duty. And I will never, never deny the God upon whom our laws and our country depend."

Flirting with presidential bid, failing to win governorship

The Ten Commandments standoff led to national fame for Moore, and he flirted with running for president, courted by the Constitution Party. Ahead of the 2012 cycle, Moore visited Iowa and seemed poised to run on the GOP line, but he ultimately didn't enter the fray.

He did make two failed statewide bids for governor. In 2006, he unsuccessfully challenged incumbent Republican Gov. Bob Riley, losing by an almost 2-to-1 margin. A 2010 bid didn't pan out any better, with Moore finishing a fourth in the primary, getting 19 percent of the vote. The man who won that race, Robert Bentley, is the one who appointed Strange to fill the vacancy left by now-Attorney General Jeff Sessions' resignation.

Bentley himself resigned earlier this year amid a sex scandal. The optics of him appointing Strange, who as the state attorney general was investigating possible misuse of his office to cover up the alleged affair with an aide, greatly hurt Strange in the race with Moore, according to several local observers.

Those two lackluster statewide performances is one reason Moore wasn't expected to gain much steam when he first entered this Senate race, but with the election of Trump, a rise of political outsiders, a reigniting of the culture wars and vulnerabilities by Strange, there was a perfect storm for him to finally grasp the nomination.

Back on the bench — then suspended over same-sex marriage

In 2012, Moore successfully won back his seat on the state Supreme Court, just less than a decade after being removed from the bench. After winning the GOP nomination — defeating another appointed judge despite being heavily outspent — the race turned unexpectedly competitive, given Moore's history — a similar scenario to what worries Republicans now.

As NPR's Debbie Elliott reported at the time, Democrat Bob Vance tried "to forge a fragile coalition of Democrats and the establishment Republicans who aren't comfortable with Moore's religious crusades." Moore eventually narrowly prevailed with 52 percent of the vote.

He didn't resurrect his Ten Commandments monument, but when the United States Supreme Court issued a ruling in 2015 legalizing gay marriage, Moore ordered state judges to defy it and instead enforce the state's ban on same-sex marriage.

"The Court's (Obergefell) opinion speaks repeatedly of homosexuals being humiliated, demeaned, and being denied 'equal dignity' by a state's refusal to issue them marriage licenses," Moore wrote in response to Obergefell v. Hodges. "The majority seeks to invoke the grief, sorrow and compassion associated with a Greek tragedy. Riding a tidal wave of emotion, the ensuing tears and pathos then suffice to fertilize a new constitutional right nowhere mentioned in the Constitution itself."

That action resulted in another appearance before Alabama's Court of the Judiciary and he was suspended for the rest of his term; however, Moore's age had already precluded him from running again in 2018. He retired from the court and then jumped into this Senate race earlier this year.

Moore has long been an opponent of same-sex marriage. CNN unearthed comments from 2005 where Moore said that "homosexual conduct" should be illegal and compared such acts to bestiality.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.