58 men were dead and 16 beheaded, in the deadliest single prison riot In Brazil in decades

As the prison burned and inmates screamed, the guards stood in their tower, clutching their guns, watching the hellish scene unfold.

"Check it out, they're going to kill the prisoner!" one observed.

"Oh, man, they got him."

"Yeah, he went down."

"Dude, this is going to be very ugly."

A deadly fight had erupted between gangs at the Altamira prison, a low-slung concrete compound surrounded by jungle in Brazil's northeastern state of Para. But rather than restore order, the guards - outnumbered by inmates 10 to one - watched it as if it were a soccer match, recording it on cellphones and offering commentary, video provided by a lawyer for several inmates shows.

By the end of the day Monday, 58 men would be dead, 16 of them beheaded, in the deadliest single prison riot here in decades. And Latin America's largest country would again be confronted by the grisly reality of its prison system - that where the state should wield the most control, it often seems to have the least.

In the past two years, hundreds of people have been killed in prison riots that in many cases raged unchecked until dozens were dead. In May, 55 inmates at prisons in Amazonas state were strangled or stabbed to death on a single day - some in front of their visiting families - when a power struggle between warring gangs exploded into horrifying violence. And in January 2017, more than 140 people were killed in riots at prisons across the country.

The problem is simple enough to diagnose: Too many prisoners and not enough room. The prison population has nearly doubled in the past decade, from 450,000 to more than 800,000. But the number of prisons, cells and guards hasn't kept pace. Some prisons are so packed that inmates have to sleep standing, and guards are so outnumbered that they've relinquished control.

The crisis has revealed a mounting official callousness toward prisoners and suspects. Violent crime peaked in Brazil in 2017 with a record of 63,880 homicides. Now, a new wave of politicians has won power by promising, in increasingly extreme language, to crack down on crime.

President Jair Bolsonaro has described plans to "stuff prison cells with criminals." Asked this week if more security was necessary at Altamira, he responded: "Ask the victims of those who died in there what they think."

Brazil, the world's fifth-largest country, has the third-largest prison population, behind only the United States and China. But its prisons, rather than serving as a deterrent to crime, have amplified it, analysts say.

With access to cellphones, weapons and armies of inmates, incarcerated gang leaders use prisons as headquarters to wage bloody campaigns for control of the country's lucrative drug routes.

In Brazil, where the developed and developing worlds collide, many of the most troubled facilities are run by states in the poorer and forested north. The gangs there are often wealthier and more powerful than the local governments.

"Organized crime has effectively corrupted and co-opted the state," said Rob Muggah, co-founder of the Igarape Institute, a Rio think tank that studies violence. "The government has effectively ceded control to drug trafficking factions."

Rights groups have exposed an intricate system of violence and crime inside the prisons. Buildings are divided by gang allegiance. In some institutions, Human Rights Watch has reported, the guards hand over keys to "chaveiros" - keymen - who dictate extortion and payment schemes.

Upon entering a prison controlled by inmates, lawyers say, new prisoners - even those with no prior affiliation - are forced to join a faction.

This has transformed prisons into powerful tools of gang recruitment. The First Command of the Capital gang, based in Sao Paulo, launched a nationwide effort in 2014 to recruit 1,000 members monthly and quickly became the country's largest and most powerful group.

By 2016, with thousands of members, it launched a war on the country's second-most powerful gang, the Red Command, based in Rio de Janeiro, for control of the drug routes stretching from Brazil to Colombia, Peru and Bolivia.

The war - in part to blame for 2017's record in homicides - raged in the streets and behind bars.

Prison riots, which had erupted only periodically in the 1990s and 2000s, were suddenly leading newscasts every few months. And they were getting progressively bloodier. Some inmates were stabbed to death. Others were decapitated.

"This horrific practice has, as we can easily understand, a great impact," said Jean-Francois Deluchey, an associate professor in political science at the Federal University of Para. "When you become an inmate . . . you are keen to become a member of the criminal organization that is capable of such a massacre, instead of adhering to the organization whose members have been recently slaughtered."

Advocates worry that the government's tough policies and politicians' contempt for prisoners will only make matters worse.

"Brazil is a violent country, so people feel that they want harsher treatment, and isolating people in these conditions is the best response," said Maria Laura Canineu, the Brazil director of Human Rights Watch. "They don't understand that these abusive conditions only encourage gang violence."

At Altamira, many of the themes bedeviling the prison system at large were playing out in microcosm.

It had a capacity of 163 detainees but was housing 343, overseen by just 33 guards, the National Justice Council said in a report this month. The council described the conditions inside the prison as "terrible" and concluded that the need for a new prison and to increase the number of guards was "urgent."

The prison, which didn't respond to requests for comment, has two main cell blocks: one for Class A Command, an affiliate of the First Command of the Capital, and one for Red Command. New arrivals had to chose.

"Either you're part of the gang or you're a sympathizer," said Ivonaldo Lopes, an attorney who says he has represented at least 100 inmates inside of the prison and who provided the cellphone video of Monday's riot recorded by the guards. "People can't declare themselves as neutral."

Joao Batista Uchoa Pereira, the director of Foundation to Live, Produce and Preserve, a local service agency, has worked in the prison for nearly two decades trying to help inmates reform.

"The climate is very intense," he said. The guards inside were unarmed and could survive only by befriending the inmates.

Deadly violence erupted last September, when inmates set fires and killed six fellow inmates.

"You could still see the burned walls," said Lopes, the lawyer. "Smoke on the walls and burned cells, and the lawyers' room was completely destroyed."

There were signs of worse to come.

Last week, Batista said, "we found a television that had weapons inside."

"They were getting ready for some action. We had meetings with the prison principal, and she'd been mentioning that their behavior was becoming more aggressive."

At 7 a.m. Monday, members of the Class A Command broke out of their cellblock and launched an attack on the Red Command. They lit a fire, Batista said, and piled on mattresses. It was soon an inferno.

From outside, atop the surveillance tower, guards watched for escape attempts as the melee escalated from riot to slaughter.

Dogs barked. Men screamed.

"Dude, I saw a head of a guy!" a guard shouted.

"Seriously?"

"Next to the fire . . . I saw it. I swear to God."

The camera focused on a platform. Through a black haze, bodies could be seen lying on the floor. A man was waving what appeared to be a machete.

"They're cutting their heads," a guard said.

"There are two heads there," another said.

Manoella Batalha da Silva, president of the Brazilian Bar Association in Altamira, said it was worse than a horror film: "heads inside shopping carts, and prisoners playing soccer with heads."

The battle dragged on for five horrific hours, until noon, when the chaos finally subsided. It was unclear whether authorities had finally stepped in to quell the violence, or the gangs had simply tired. Families still don't know the complete picture.

Ronivia Teixeira Pontes had thought her brother had died of asphyxiation - until she saw his body. It was burned, blackened. "I don't even know who he is," she said. "He's unrecognizable. . . . Burnt alive."

"Everybody heard about" the riot before it happened, she said, anger welling in her voice. "And they did nothing. They let everything happen."

Officials moved to separate gang leaders, shipping some to federal prisons. Four of them died during transport of asphyxiation, though the exact circumstances remain uncertain.

On Tuesday, as families continued to clamor for information about loved ones inside the prison, Batalha went inside for the first time since massacre.

A meat truck had taken away the bodies. The inmates inside were in shock. In five hours, the prison population had shrunk by one-sixth.

But the mood inside the prison was the same as it was before the riot.

"Tense," he said.