Mr. Ellison’s lawyer, Deveraux L. Cannick, told jurors during closing arguments that Mr. Hernandez, who was indicted last year along with other gang members and pleaded guilty to multiple offenses, faced a minimum sentence of 47 years in prison. The sentence could only be lessened, Mr. Cannick said, if prosecutors wrote a letter saying the rapper had provided valuable assistance to the government.

“You don’t think he would do whatever he needs to do to go home?” Mr. Cannick asked. “There’s a motive to lie here.”

During the trial, prosecutors portrayed Nine Trey as a violent criminal enterprise that reaped profits through robberies and by trafficking large amounts of narcotics, including heroin and fentanyl.

One of the principal dealers, they said, was Mr. Cruz, who in his testimony named leaders and identified factions within the gang. Mr. Cruz also outlined how he combined kilograms of heroin, fentanyl and a third substance that together cost about $60,000, then divided the mixture into three packets of a kilogram apiece that he marketed as pure heroin. Each of those kilograms sold for $47,000, he testified.

But the most striking moments of the trial involved Mr. Hernandez, a flamboyant figure known for rainbow-dyed hair, facial tattoos and a history of profane provocations, including social media videos taunting rival rappers.

Mr. Hernandez joined Nine Trey in 2017, but left less than a year later as the group descended into infighting. By that time Mr. Ellison, described as an old-school gangster purist, had withdrawn his protection from Mr. Hernandez and mocked him as a fraud.

On the stand, Mr. Hernandez shed his public persona and acknowledged that he had joined the gang for credibility and protection, and as a way to boost his music career. He attributed the viral success of some of his YouTube videos to the fact that they included Nine Trey members wearing red bandannas and brandishing pistols on the streets of Brooklyn.