The next day, Mr. Hernandez cut a deal with prosecutors, he said in court on Tuesday.

Mr. Hernandez pleaded guilty in February to charges stemming from the racketeering case, and admitted then in court to being a member of the gang from 2017 to 2018.

He spoke more in detail about his involvement in the gang on Tuesday.

“We participated in a lot of crimes,” he testified. “Robberies, assaults, drugs.”

In a clear voice, Mr. Hernandez laid out for prosecutors the internal workings of the Nine Trey gang, one of the country’s most robust prison crews, which was founded more than 25 years ago on Rikers Island.

His testimony was stunning at times in its directness. Prompted by prosecutors, Mr. Hernandez eagerly translated gang codes for the jury, and listed by name the hierarchy of his former Bloods set.

At the time of his guilty plea, prosecutors said they intended to lobby for Mr. Hernandez to receive a lesser sentence if his cooperation proved successful.

Mr. Hernandez’s turn on the witness stand was not entirely unforeseen: Days before his arrest last November, he had a public falling out with the Nine Trey gang, precipitated by his kidnapping last summer for which Mr. Ellison is now charged.

At the time of the kidnapping, Mr. Hernandez’s professional prospects were rife with conflict. While feuding with the Nine Trey gang over control of his career, Mr. Hernandez’s manager was also encouraging him to cut ties with the gang altogether.