At least 57 people have been killed in a gruesome gang battle that broke out in a prison in the Brazilian Amazon on Monday morning.

Officials said a local drug gang had invaded the wing controlled by its rivals in the city of Altamira in the state of Pará, decapitated 16 prisoners and set mattresses on fire, with dozens more thought to have been asphyxiated in the smoke.

Security specialists blamed a war across the Amazon region for control of the lucrative drug trade, which is also believed to have been the reason for the killing of 56 prisoners in a prison in the Amazon city of Manaus in 2017 and a series of bloody revenge killings that ensued.

Jarbas Vasconcelos, the penitentiary system superintendent for the state of Pará, told reporters that the violence had begun at around 7am as breakfast was being served to prisoners in the regional recuperation centre of Altamira, a city of 109,000 people. The prison held 343 prisoners, more than twice its capacity, the G1 news site reported.

Prisoners from the local Comando Classe A (CCA) gang, or Class A Command, broke out of their wing and attacked another wing controlled by the Comando Vermelho (CV, Red Command) – a powerful drug gang from Rio whose operations spread across Brazil. Two guards were held hostage and later released.

“We found decapitated bodies and rest were asphyxiated,” Vasconcelos said. “The situation has been controlled. It was an attack by one criminal organisation on the other. They entered, set fire and killed, and ended the attack.”

The gunshots and screams could be heard in the neighbouring airport. “It lasted about 30 minutes. It was horrible,” said Larissa Castro who works on the reception of a car rental company. Military police sent a detachment to reinforce security at the airport. Medical staff at the local hospital said many of those brought for treatment were very seriously wounded. Authorities said 46 prisoners involved in the conflict will now be transferred.

The city of Altamira’s population has boomed in recent years as workers flooded in to build the controversial Belo Monte hydroelectric dam. Riverside communities were moved to the growing city as huge areas were flooded. As low-income communities mushroomed, crime and drugs spread.

“There was a population explosion. This increases inequality and it is a market for drugs,” said Edson Ramos, a professor of statistics at the Federal University of Pará who advises the Brazilian public security forum.

Much of the cocaine being trafficked to Europe and Brazil flows down the Solimões River, in the neighbouring state of Amazonas, and Pará was increasingly coming under the gaze of drug gangs, said Aiala Couto, a professor of geography at the State University of Pará and urban violence specialist.

The trade in Amazonas is controlled by the Família do Norte (FDN, Northern Family), blamed for the New Year’s Day 2017 massacre that killed 56 prisoners in a prison in Manaus, many linked to the rival Primeiro Comando da Capital (PCC, First Capital Command) gang from São Paulo.

Since then, the PCC’s power in the region has been reduced as their rivals the Red Command increased their presence. The CCA has been getting close to the FDN, Couto said – but it has also been sought out by the PCC.

“The prison is commanded by the Class A Command and it is their way to intimidate the ever growing presence of Red Command in the state,” Couto said. “The idea is to stop the Red Command arriving in Altamira.”

Additional reporting by Jonathan Watts in Altamira