That Ronald Herron would be sent to prison for the rest of his life was a foregone conclusion when he strode into Brooklyn federal court on Thursday, winking and smiling at friends and family.

But before that happened, Mr. Herron, 33, a onetime rapper who performed under the name Ra Diggs, and who was convicted of violently running a branch of a notorious drug gang and killing three people, set off fiery exchanges involving his supporters, the judge, prosecutors, the weeping sister of one of his victims and court officers.

“You guys sit here and continue to paint this picture that I’m the devil incarnate, the scourge of righteousness — it’s all crap,” Mr. Herron said, seething at prosecutors before he was sentenced. “Even the most dim prosecutor could have secured a conviction under this atmosphere of guilt they built. They did all but point a big, red arrow of guilty up on that projection screen.”

Judge Nicholas G. Garaufis sentenced Mr. Herron to 12 life terms plus 105 years. He told Mr. Herron that his speech proved that he was smart and well-spoken, and that he possessed not a scrap of empathy for his victims.