Imran Shahid, who is serving life for leading the gang which kidnapped and killed Kriss Donald, was working out when his attacker struck at Kilmarnock prison in February.
Murderer William Crawford, 25, admitted the attack at the town's sheriff court.
Prosecutor Bernard Ablett said Shahid had started going to the gym with fellow prisoner Bernard Bisset.
He said Shahid had been using a rowing machine when the accused lifted a 15kg weight and struck the top of his victim's head from behind, before throwing the weight onto his chest and stamping on him.
He added: "Other prisoners with metal poles repeatedly struck Shahid's head and body with the metal poles."
When Bisset intervened he was chased and attacked.
Shahid suffered a fractured jaw and cheekbone, shattered teeth and cuts, bruises and swelling to his face and head.
Crawford admitted striking Shahid repeatedly in the head and body with weights and bars, kicking him repeatedly on the head and body and repeatedly stamping on his head, to his severe injury and danger of life.
He also admitted punching and kicking Bisset repeatedly on the head and body and striking him repeatedly with metal bars. Sentence was deferred for reports.