NEW YORK -If there was any last, faint hope for Richard A. Dietl, the garrulous former police detective and current mayoral hopeful, to return to the Republican Party to challenge Mayor Bill de Blasio in the November election, it faded permanently on Thursday.
A day after hearing brief arguments, a state appeals court in Manhattan issued a terse statement upholding a State Supreme Court judge’s decision that Mr. Dietl, known as Bo, had been properly listed as “blank” on voter registration rolls after he tried to change his party affiliation to Democrat but mistakenly filled in two boxes.
Without being registered as a Democrat or a Republican, Mr. Dietl cannot run in either party’s mayoral primary in September, relegating him to campaigning as an outsider in his quixotic quest to oust Mr. de Blasio, the incumbent.
The ruling, by a five-judge panel of the First Department of the Appellate Division, came after a decision last month by county Republican officials not to grant Mr. Dietl a waiver allowing him to enter the party’s primary. And it came amid what had already been a bad week for the often vulgar candidate, beginning with a Staten Island Advance reporter’s disclosure on Tuesday of an aggressive text message exchange between Mr. Dietl and Frank Morano, the chairman of the Reform Party on Staten Island.
“Lying worm,” Mr. Dietl wrote in the obscenity-laced exchange last week after the Reform Party endorsed Sal Albanese, a Democrat and former City Council member, for mayor. “Go find a can of Man.”
“If I could figure out what that means, I am going to make every effort to do so,” Mr. Morano said in a telephone interview on Thursday. Mr. Morano said he never told Mr. Dietl that he was going to vote for him. After the Reform Party endorsed Mr. Albanese, Mr. Morano recalled how “Bo called me out on Twitter” using an anatomical reference.
The comments resulted in negative headlines about “vulgar texts” that were followed the next day by a Daily News report that Mr. Dietl had financial ties to a marijuana testing company that is under federal investigation.
Despite having raised more money than every other candidate besides Mr. de Blasio and Paul J. Massey Jr., a millionaire Republican, Mr. Dietl saw his political star fade after he made racially charged comments at a Republican candidate forum attacking the state court judge who ruled against him in the voter registration case.
Mr. Dietl said that the judge, Debra A. James, resembled Mr. de Blasio’s wife, Chirlane McCray, and so he knew he “had a problem.” Both women are black.
Mr. Dietl was not in court on Wednesday. He was represented by Martin E. Connor, a respected election lawyer, who described the case as a simple one about reading the plain language of the law: If a person checks two boxes, that person becomes a blank, unless they have provided an address with a prior party registration.
Mr. Connor argued that because Mr. Dietl listed his Nassau County address, where he was registered as a Republican, the city Board of Election should have checked the state database and registered him a Republican when he enrolled as a new voter in New York City late last year.
The board, in its argument, disagreed, and the judges sided with the board.
“This could be a blessing in disguise, the way Republicans run in this city,” Mr. Dietl said in an interview on Thursday, referring to the unpopularity of President Trump, for whom he voted. “I’m running as a full independent.”
Mr. Dietl suggested that the judges had been influenced by Mr. de Blasio, pointing to the presence in the courtroom of Henry Berger, Mr. de Blasio’s special counsel, who had come to hear the argument by Mr. Connor, but left before it began.
“What was his general counsel Berger doing in the courtroom other than causing influence to the judges?” Mr. Dietl said. (“That theory is pure fantasy,” said Eric F. Phillips, the mayor’s press secretary.)
Of the marijuana business, Mr. Dietl said, “I like medical marijuana and I’d like to explore the fact of recreational marijuana in this city. I never seen a guy smash a bottle over somebody’s head high on pot.”
He said that he never used the drug himself.