Brasilia: A revolt at a prison in the Brazilian state of Parana that left four inmates dead came to an end after prisoners and authorities reached an accord.
The rebels agreed to surrender and release two guards they were holding hostage after the state government agreed to transfer some 800 inmates to other institutions.
The departing inmates will go to prisons with better conditions.
No more than 300 prisoners will remain at Cascavel State Penitentiary once the transfers are complete.
At least four inmates were killed - two of them decapitated - during the uprising that began early Sunday, but a judge who took part in the negotiations leading to the agreement said the actual death toll could be much higher.
Inmates' families have been gathered outside the prison since Sunday hoping for news about their loved ones.
Around 600 of the 1,040 inmates at Cascavel took part in the rebellion to demand improved food and conditions and an end to abuses by guards, the Parana state justice department said.
One of the two inmates beheaded by the rebels was a former police officer.
The mutinous inmates occupied the roof of the prison, where they set fire to mattresses and held up signs bearing the initials PCC, referring to the First Capital Command, the largest criminal outfit in the neighbouring state of Sao Paulo.