The riot broke out Sunday in southern Brazil's state of Parana. Five inmates were killed in the melee, xinhua reported.
The state secretariat of justice said nearly a thousand inmates took part in the riot, which saw two prison guards taken hostage for 45 hours, before the situation was brought under control.
Rioters had decapitated two of the inmates and tossed the bodies of another two from the facility's 15-meter-high rooftop.
At least 25 people were injured in the riot.
At least 80 percent of the facility was damaged in the tumult, which ended after officials transferred 851 of the 1,040 prisoners to other jails with better conditions.