At least 57 inmates died, with 16 decapitated, in a prison riot on Monday in the northern Brazilian state of Para, the state's prison authority said, underlining the struggle Brazil's far-right government faces to restore order in the country's jails.

State authorities said the riot began around 7 a.m. on Monday in a prison in the city of Altamira, and involved rival criminal gangs who took at least two penitentiary officers hostage as they battled one another.

Elected on a tough-on-crime message, far-right President Jair Bolsonaro has benefited from a sharp drop in homicides this year. Nonetheless, endemic prison violence serves as a reminder of the ongoing public security challenges he faces in one of the world's most violent countries.

The grisly riot is the latest deadly prison attack this year. At least 55 inmates died in May during an attack in a lockup in the northern state of Amazonas. In 2017, weeks of violence in Amazonas resulted in 150 prison deaths as local gangs backed by Brazil's two largest drug factions went to war.

Brazil's incarcerated population has surged eightfold in three decades to around 750,000 inmates, the world's third-highest tally. Its prison gangs have come to wield vast power that reaches far beyond prison walls.

'Terrible' conditions

The Associated Press obtained a July 2019 report from the National Justice Council that it says was filed by a local judge in charge of the facility, showing that the prison had 343 detainees for a maximum capacity of 163.

But Vasconcelos said the situation did not meet the official requirements to be considered overcrowded. "It is not a unit that has a prison overcrowding. We consider overcrowding when it exceeds 210 per cent," Vasconcelos said during the news conference.

The judge who filed the report described the overall state of the prison in the city of Altamira as "terrible."

Originally formed to protect inmates and advocate for better conditions, Brazil's prison gangs are now involved in bank heists, drug trafficking and gun-running, with jailed kingpins presiding over their empires via smuggled cellphones.

In the violent northeast, prison gangs have grown powerful moving cocaine from Colombia and Peru along the Amazon's waterways to the Atlantic coast, where it heads to Africa and Europe. Murderous disputes often arise as they clash over territorial control.

Bolsonaro's government has proposed moving powerful incarcerated drug lords to federal lockups, and building more prisons at the state level. However, with the vast majority of prisons run by Brazil's overstretched state governments, Bolsonaro is limited on what he can achieve from Brasilia.

In February, Justice Minister Sergio Moro unveiled his signature crime-fighting bill, which includes proposals to toughen prison sentences and isolate gang leaders in maximum-security lockups.

That bill, however, has struggled in Congress, with the government prioritizing its pension reform bill.

Para state prison authorities said 16 of the victims were decapitated while others were asphyxiated.

'It was a targeted attack'

The count of victims could rise when authorities have searched all areas involved, state prisons chief Jarbas Vasconcelos said at a news conference.

Vasconcelos said a fight between criminal groups at the Altamira prison erupted around 7 a.m. AT, when breakfast was being served.

"It was a targeted attack. The aim was to show that it was a settling of accounts between the two groups, not a protest or rebellion against the prison system," Vasconcelos said.

Authorities have not found any firearms following the riot, only makeshift knives.

Prison authorities said 46 inmates will be transferred to other prisons, 10 of which will go to stricter federal facilities.

Inmates also set fires that prevented authorities from entering parts of the facility for about five hours, he said.

The killings echoed those of 55 inmates who died in a series of riots in May in several prisons in the neighbouring state of Amazonas.

In early 2017, more than 120 inmates died in prisons across several northern states when rival gangs clashed over control of drug-trafficking routes in the region. The violence lasted several weeks, spreading to various states.

In many of Brazil's prisons, badly outnumbered guards struggle to retain power over an ever-growing population of inmates who are able to run criminal activities from behind bars