(CNN)Long before former Alabama Chief Justice Roy Moore became a political insurgent, he was regarded as a judicial pariah.
Roy Moore: The judge who fought the law
Even judges who agreed with Moore's opposition to same-sex marriage last year could not abide his defiance of federal law. And in an earlier episode, even those who were open to religious displays in public buildings could not tolerate his refusal to remove an enormous Ten Commandments monument deemed unconstitutional.
For the unanimous members of the Alabama Court of Judiciary that ousted him from the bench -- twice -- it was not Moore's substantive views but his sheer lack of integrity and impartiality. In a 50-page final judgment against him last year, phrases like "grossly inconsistent with his duties" and "incomplete, misleading and manipulative" leap out.
Moore appears poised to be the next US senator from Alabama after winning the Republican primary Tuesday, defeating Sen. Luther Strange, who was endorsed by President Donald Trump. The rebellious far right-wing agenda that made Moore a judicial anomaly now seems politically popular, at least in his Dixie state.
It's a strong turnaround from this time last year, when Moore was suspended from the bench.
In its decision faulting Moore for ordering probate judges not to issue marriage licenses to gay men and lesbians, the Alabama Court of the Judiciary declared: "This case is not about whether same-sex marriage should be permitted. ... Moreover, this is not a case to review or to editorialize about US Supreme Court's June 2015 (decision declaring a right to same-sex marriage, Obergefell v. Hodges), a decision that some members of this court did not personally agree with or think was well-reasoned."
The panel emphasized that the dispute came down to his failure to comply with the law and avoid impropriety.
In a statement at the time, Moore said: "This was a politically motivated effort by radical homosexual and transgender groups to remove me as Chief Justice of the Supreme Court because of outspoken opposition to their immoral agenda."
Moore had ordered Alabama probate judges not to follow the Supreme Court's ruling. He declared Obergefell "manifestly absurd and unjust ... contrary to reason and divine law ... not entitled to precedential value."
The Court of the Judiciary, a nine-member panel made up of Alabama judges, lawyers and appointed citizens, noted that his order would "put 68 probate judges in direct defiance of federal law." It said that made the same-sex marriage controversy "worse than" the actions that led up to his 2003 removal from the bench.
The earlier situation arose from Moore's 2001 unveiling of a 5,280-pound granite monument of the Ten Commandments in the State Judicial Building. A federal trial judge ruled that Moore violated the First Amendment's imperative that government "shall make no law respecting an establishment of religion."
Moore became Alabama chief justice in January 2001. Earlier, as a circuit court judge in Gadsden, Alabama, he had displayed a plaque of the Ten Commandments in his courtroom and invited clergy to lead prayers before trials.
In the dispute over the granite block topped with the Ten Commandments depiction, the federal judge said it was so massive and so different from anything else in other public places that it plainly signaled an endorsement of religion, under multiple US Supreme Court precedents. The judge rejected Moore's contention that the US Supreme Court failed "to understand the historical relationship between God and the state."
Moore lost appeals to the US Court of Appeals for the 11th Circuit and the US Supreme Court but still refused to move the monument.
When the Alabama Court of the Judiciary took up a related ethics complaint, it said it was not casting judgment on "the acknowledgment of God" in a public building.
"Indeed, we recognize that the acknowledgment of God is very much a vital part of the public and private fabric of our country," the court said. Yet it concluded, "the highest judicial officer of this state had decided to defy a court order" and must be removed from office.
Moore, who lost bids to be Alabama governor in 2006 and 2010, ran again for the chief justice position in 2012 and was elected.
He was soon back in the crosshairs. After his latest removal, the Court of the Judiciary wrote of his pattern of "taking actions grossly inconsistent with his duties as chief justice":
"The result in both instances has been a lengthy, costly proceeding for this court ... and most unfortunately, the taxpayers of this state."