Brazil's incarcerated population has surged eight-fold in three decades.

Highlights A clash between two prison gangs left at least 57 inmates dead

Authorities say riot began around 7 am local time at a prison in Altamira

Most dead died in fire, 2 guards were taken hostage, but later released

A bloody clash between two prison gangs on Monday left at least 57 inmates dead with 16 of them decapitated, authorities in the state of Para said, the latest deadly clash as Brazil's government struggles to control the country's overcrowded jails.

State authorities said the riot began around 7 a.m. local time (1000 GMT) at a prison in the northern city of Altamira, and involved rival gangs.

Prisoners belonging to the Comando Classe A gang set fire to a cell containing inmates from the rival Comando Vermelho, or Red Command, gang, Para's state government said in a statement.

Most of the dead died in the fire, they said, while two guards were taken hostage, but later released.

"It was a targeted act," state prison director Jarbas Vasconcelos said in the statement, adding there was no prior intelligence that suggested an attack would take place.

"The aim was to show that it was a settling of accounts between the two gangs."

Videos circulating online showed inmates at the prison celebrating as they kicked decapitated heads across the floor. Reuters was unable, however, to independently verify the footage.

Two security guards were taken hostage during the riot.

Elected on a tough-on-crime message, far-right President Jair Bolsonaro has benefited from a sharp drop in homicides so far this year. Nonetheless, endemic prison violence has been a stubborn public security challenge in one of the world's most violent countries.

In May, at least 55 inmates died during prison attacks in the northern state of Amazonas. Weeks of violence in Amazonas in 2017 resulted in 150 prison deaths as local gangs backed by Brazil's two largest drug factions went to war.

Brazil's justice ministry said in a statement that it was working with Para authorities to identify those behind the latest attack, adding it had opened some space in the federal prison system where those gang leaders would be transferred.

Brazil's incarcerated population has surged eight-fold in three decades to around 750,000 inmates, the world's third-highest tally. Prison gangs originally formed to protect inmates and advocate for better conditions, but have come to wield vast power that reaches far beyond prison walls.

The gangs have been linked to bank heists, drug trafficking and gun-running, with jailed kingpins presiding over criminal empires via smuggled cellphones.

In the country's violent northeast, prison gangs have grown powerful by 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.

The Red Command hails from Rio de Janeiro, but has expanded deep into northern Brazil as it seeks to diversify its income. That expansion has often led to confrontations with Brazil's largest and most powerful gang, the First Capital Command, headquartered in Sao Paulo.

The Comando Classe A gang is seen as a relatively small gang, and is little known outside Para. Its high-profile attack against the Red Command could give it a nationwide reputation.

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

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

That bill has since struggled in Congress, with the government giving its pension reform legislation priority.