Brazilian authorities have reached a deal with rioting prisoners who killed four fellow inmates, beheading two of them, and held two guards hostage.

Elson Faxina, a spokesman for the Parana state attorney's office, said an agreement was signed on Monday to end the unrest at the Cascavel city correctional facility and that prisoners were currently being transferred to another jail.

"After that, the two guards who were held hostage will be freed," Faxina said, adding that police still had to enter the jail to assess the damage and determine if there are more victims.

Some 800 inmates - or 80 percent of those being held at the facility - took part in the revolt, he said.

The riot erupted on Sunday as breakfast was being served, with inmates overpowering guards.

Two prisoners were beheaded in the first surge of violence, and two others were thrown off the top of the cellblocks.

The guards were taken hostage in the riot.

An official with the guards' union said only 10 wardens were on duty at the time. Prison authorities said the inmates were demanding improved facilities, better quality food and more flexible visiting hours.

But the inmate-on-inmate violence also suggested that rivalries between competing prison gangs played a role in the uprising.

Television images had shown some of the rioting inmates - dressed in orange jumpsuits with their faces obscured - on the roof of the facility during the mutiny.

Overcrowding

Police have yet to identify the four inmates who were killed and retrieve the remains of the two who were beheaded, according to authorities.

The state correctional centre, which houses 1,140 inmates, has a capacity for 1,181, according to official data.

Anthony Johnson, president of the prison guard union in Parana state, said the true capacity of the facility was just 900.

"So there's overcrowding," he said. "For us, the situation is tense now but we hope it is resolved. A jail of this kind needs investment."

According to the union of prison workers, a major lack of investment plagues the system, and the facility was threatened by a scarcity of operational and technical professionals as well as proper maintenance.

Brazil holds 548,000 inmates in its prisons, but needs 207,000 more spaces to avoid overcrowding, according to the NGO Conectas Human Rights.