Judge William McLeod was back in court. But this time, instead of hearing Harris County civil cases from his seat on the bench, he was fighting tears, trying to convince five local lawmakers that he should be allowed to keep his post.

The law — at least in the county commissioners court on Tuesday — was not on McLeod’s side, the legislators said. They ruled against him, 3 to 2, a verdict that surprised some who expected the court’s Democratic majority to support the liberal judge. Yet it was the two Republicans who backed McLeod.

The turn from judge to judged was McLeod’s last stand in a bizarre legal and political fight that broke out after officials in the Harris County Attorney’s Office ruled that McLeod had resigned from his position.

But there was one complication: He quit by accident.

McLeod, who took office in January, had decided by March that he wanted to run for the Texas Supreme Court. So, he did what candidates for higher office normally do in that state: filed paperwork with the Texas Ethics Commission declaring his intentions and updated his campaign website to reflect his new ambitions.

It was these steps, the county attorney argued, that inadvertently invoked Article 16, Section 65 of the Texas constitution, which considers any declaration of candidacy for another office an automatic abdication of that official’s current position. After realizing his error, he quickly removed from his website the references to his Supreme Court run and retracted his announcement, saying he’d rather finish his four-year term as county judge. But, he was told, it was too late.

So there McLeod was on Tuesday, in front of the Harris County Commissioners Court, the legislative body that controlled his fate, arguing his case.

“This is the Texas constitution,” he said, holding up a thick stack of papers during the meeting. “It’s got 496 amendments. It’s over 87,000 words. It’s the second-largest state constitution in our Union, and I’m sorry I didn’t have it down."

Under the constitution’s holdover provision, McLeod argued, the commission could leave him be. He asked that they consider the entire constitution — if one provision could force him out, the other could keep him in. He said he made a mistake, and he asked for leniency.

“I have always had the best interest of every single resident of our Harris County at heart,” he said. “I apologize and accept ownership of this mistake.”

McLeod, who is on social media and involved in local activism, rallied a large group of supporters to attend the hearing. Many spoke on his behalf, mixing constitutional legalese with testaments to the judge’s character.

“He shows up for people whenever there’s a need,” said Daniel Cohen, the president of the Houston chapter of Indivisible, a left-wing political advocacy group.

One speaker brought with her a poster board on which she highlighted her legal argument for McLeod.

But the commissioners argued that it could be a liability to retain McLeod as a holdover, because he may have to recuse himself from cases where the county was a party — a potential conflict of interest because McLeod may feel indebted to a commission that could remove him at any time.

“Judge, this is something we did not create; we wish we weren’t in this situation,” Lina Hidalgo, a Democrat and head of the commissioners court, told McLeod during the meeting. “Voters deserve a judge who can be absolutely independent as he was elected to be.”

Democratic commissioner Adrian Garcia thanked McLeod for his service and told him that “nothing is more painful than to have to make difficult decisions.”

In McLeod’s place, the lawmakers appointed Lesley Briones, a Houston lawyer and Yale Law School graduate. Briones, who said she supported McLeod’s election, also had several attendees speak on her behalf.

“I deeply believe in justice and fairness for all,” she said after she was named McLeod’s successor. “I voted for Judge McLeod, and I have deep respect for you, sir. … Thank you for your trust, and I hope to earn the trust of the public.”

The pair of Republicans on the commission criticized Briones's appointment for what they called a lack of transparency. They said that they hadn't been given a chance to review her credentials.

"The unfairness of the process was overwhelming,” said Steve Radack, one of the commission’s Republicans, the Houston Chronicle reported.

After the ruling, some of McLeod’s disgruntled backers vowed they would mount an effort to replace the lawmakers who voted against him.

“Every single commissioner should be primaried in the next election because they just stole the voice and the vote and the will of the people,” Ashton P. Woods, a Houston City Council candidate and founder of the city’s Black Lives Matter chapter, said in a Facebook video. “People voted overwhelmingly to put William ‘Bill’ McLeod into office.”

McLeod, in an interview with The Washington Post after the vote, said he would stay on until April 26 to ensure a smooth transition. He also said he wouldn’t pursue a lawsuit against the county because it could prove costly for taxpayers.

His old seat will be open again in 2020. And the Texas Supreme Court will have a few vacancies, too.

But he wouldn’t say whether he’d run.

Read more: