RIO DE JANEIRO — Relatives of inmates killed during a prison riot in northern Brazil gathered in the coroner’s office Tuesday to identify the 58 victims, with some passing out at seeing the beheaded corpse of a loved one.

Seeking to prevent further violence at the Altamira prison in Para state, where gruesome violence Monday included 16 decapitations, authorities designated all 46 inmates accused of being involved for transfer to other prisons, including stricter federal ones. Local officials said at least 33 inmates had been moved on Tuesday to the state capital of Belem for reassignment.

A worker at the forensic institute in Altamira, Marcel Ferreira, described the anxiety among the relatives waiting outside the coroner’s office and said the office had asked local authorities, firefighters and anyone present at the scene to bring water, food or medical assistance for the family members.

“Sometimes we think that (they) are in a safe place,” said Antonia Vera Santana, a 43-year-old mother looking for news of her son, incarcerated in the Altamira prison. “But it’s a lot worse there than it is out here.”

Santana turned up at the institute at 7 a.m. Tuesday and was still waiting late in the day.

Forensic experts from neighboring cities in Para arrived to help deal with the flood of corpses. Bodies had to be stored in a large refrigerated truck rushed to Altamira after the news of yet another prison mass killing emerged.

The coroner’s office said it had released 15 bodies to families by the close of the work day.

State officials say clashes erupted early Monday when the local Comando Classe A gang attacked a wing of the prison where members of rival gang Comando Vermelho, or Red Command, were held.

Comando Classe A set fire to the temporary containers where inmates belonging to Red Command were being held while construction of another wing was underway. Most of the victims died of asphyxiation.

“This is clearly a declaration of war on the Red Command,” said Jean-François Deluchey, adjunct professor in political science at the Federal University of Para, who has been studying the region for 20 years.

Authorities have not yet revealed the exact cause of the latest attacks in Altamira, only confirming that it was a fight between criminal groups. But several recent prison massacres have been attributed to gangs clashing over control of drug-trafficking routes in the multibillion-dollar Amazon drug trade.

In many of Brazil’s prisons, badly outnumbered guards struggle to maintain power over an ever-growing population of inmates, with jailed gang leaders often able to run their criminal activities from behind bars.

In May, two days of unrest in the neighboring state of Amazonas left 55 prisoners dead in four different prisons of the state’s capital, Manaus. In 2017, more than 120 inmates died in prisons across several northern states.

“It’s the same logic, the same movement,” Deluchey said. According to him, Red Command has a strong presence in the north and is trying to expand further in the region.

Deluchey says it is hard to confirm with certainty, but initial reports indicated that Comando Classe A, a local gang thought to have been created not long ago inside the Altamira prison, is linked to another powerful Brazilian gang, First Capital Command.

“The First Capital Command is losing grounds and it looks like Comando Classe A is helping them stop the hegemony of Red Command,” he said.

The professor said that information he has gathered indicates Red Command is already saying there will be retaliations for Monday’s attack.

Gruesome violence is often used in Brazilian prisons to gain respect and send a strong message to new arrivals. “Violence is to impress, to frighten, so that new (inmates) join the side of those who decapitate, and not the decapitated.”

The latest killings represent a challenge for the far-right administration of President Jair Bolsonaro. A former army captain, Bolsonaro ran a tough-on-crime campaign, promising to curb epidemic violence in Brazil, including in its overcrowded and out-of-control prisons.

The president publicly addressed the killings for the first time Tuesday, in a video published on the online news portal G1. Asked by journalists about what he thought about strengthening security in the Altamira prison, Bolsonaro replied: “Ask the victims of those who died in there what they think.”

Brazil has the world’s third-largest prison population, behind the United States and China, with more than 720,000 individuals behind bars, according to official data from 2017. Some Brazilian prisons have more than three times as many inmates as their maximum capacity.

In the Altamira prison, a local judge counted 343 detainees in a facility authorized for a maximum of 163 people, according to a report he filed in July and reviewed by the Associated Press.

State prison authorities said Monday that the situation there does not meet their requirements to be considered overcrowded.