That murder — orchestrated by the former Gambino boss John Gotti in what would become a successful bid for control of the enterprise — led to a wave of killings, including by families outside the Gambino clan who viewed the violent power grab as a brazen violation of the Mafia’s code. Within the city’s five crime families, bosses typically are considered untouchable.

Mr. Comello’s peculiar back story complicates the problem for law enforcement. Had the murder been a straightforward assassination, the most likely source of retaliation would be the Gambino crime family.

But Mr. Cali’s murder appears to have instead been a bizarre attack unrelated to mob business. Mr. Comello has no known ties to organized crime, law enforcement officials have said. He initially told detectives he was romantically interested in one of Mr. Cali’s female relatives and had been told by the mob boss to stay away, officials said.

Mr. Comello also might have been inspired by right-wing conspiracy theories he had encountered online, his lawyer said.

Mr. Comello had recently begun acting erratically. In February, he had drawn the attention of the police after he showed up at the federal courthouse in Manhattan and at Gracie Mansion, demanding a citizen’s arrest of Mayor Bill de Blasio and other Democratic political figures.

“I’m not going to go into the specific websites, the specific words that did have an impact. But suffice it to say that whatever happened here is related,” Mr. Gottlieb said. Mr. Comello was spotted last week during his first court appearance in New Jersey with “MAGA forever,” “united we stand” and a symbol of the right-wing QAnon conspiracy theory written on his palm.

The Gambino clan had operated quietly for the better part of the last decade after federal prosecutions decimated its ranks in the 1990s. But the crime organization had continued to make money from loan-sharking, extortion and heroin, law enforcement officials have said. It remains unclear if the family would use Mafia muscle to retaliate against Mr. Comello — a rudderless young man from Staten Island’s South Shore — and risk further scrutiny from law enforcement.