Upon entering the courtroom, Mr. Mendez appeared to be in good spirits. He caught the eyes of two supporters near the back, and, at one point, he blew a kiss to a woman who identified herself as an old friend. As he was led out of the courtroom, he turned back and smiled.

Mr. Mendez admitted that he had acted with others to cause serious physical injury to a man in a basement apartment at 1910 Osbourne Place, where the gang members had congregated.

“I take full responsibility for everything that happened and that’s why I’m pleading guilty,” said Mr. Mendez, who sported braids and a large tattoo of a profanity on his arm. Still, he also insisted that he was high on drugs when the police questioned him, and that “many of the statements attributed to me in this case” were not true.

Acting Justice Steven L. Barrett, in explaining the implications of the plea, informed Mr. Mendez that because of his prior conviction for attempted criminal possession of a weapon, he would be jailed for life if convicted of another violent felony.

Mr. Mendez is expected to be formally sentenced on March 31. Under the plea deal, he will serve five years of probation after his release from prison.

The last remaining defendant, Luis Garcia, is scheduled to appear in court on Friday.

Also convicted in the attack was David Rivera, 24, who pleaded guilty to one count of burglary in the first degree after admitting that he took cash, credit cards and a television from the home of a victim. He was sentenced to 13 years in prison.

Nelson Falu, 20, pleaded guilty to one count of robbery in the first degree for threatening a victim with a baseball bat and taking personal property. He was sentenced to seven years in prison.