A riot at a jail in Brazil's Sao Paulo state has ended after inmates freed a group of guards they had taken hostage.
Rioters had been standing on the prison roof
In 30 hours of violence, the inmates beheaded at least five members of a rival gang, started fires and destroyed much of the jail.
The victims' heads were at one point displayed on stakes on the prison roof.
The riot ended peacefully following lengthy phone negotiations between the inmates and the authorities. The terms of the deal are not clear.
The BBC's Steve Kingstone in Sao Paulo says the most immediate task is to transfer about 600 prisoners to alternative facilities.
Violence is common in the country's jails, but this incident was especially shocking, our correspondent says.
The revolt began early on Tuesday at the Presidente Venceslau prison 620km (386 miles) west of Sao Paulo.
It is thought a group of inmates armed with sticks and razor blades invaded a secure wing of the jail.
They then attacked other inmates, possibly former members of the same criminal faction.
Wednesday's newspapers showed photos of rioters on the roof displaying both the severed heads and the live hostages.