NATAL, Brazil - For nearly two years, guards didn't dare enter the cell blocks at the Alcacuz prison in northeastern Brazil. And with good reason. Only about a dozen at a time are supposed to watch some 1,500 inmates, whose gangs are supplied through tunnels that let them bring in guns, knives, cellphones and just about anything else.

The lockup, nicknamed "Swiss cheese" by residents of the surrounding neighbourhood, saw a Jan. 14 riot in which 26 prisoners died - and officials here are still trying to finally regain full control.

"The state has lost control," Vilma Batista, a guard at Alcacuz and president of the correction officers union in Rio Grande do Norte state, told The Associated Press, speaking just outside the prison in the wake of the clashes. "We have lost all of the buildings in the prison where there are inmates, who remain in command and in control."

Alcacuz is among the worst prisons in Brazil, but by no means an aberration. The problems here can be found across Latin America's largest nation, which is experiencing a wave of prison massacres and unrest that have left at least 130 inmates dead since the beginning of the year.

Neglect has long been building at Alcacuz where more than 1,550 inmates are crammed into buildings meant for about 1,000.

Batista said guards - no more than 12 are on duty at any time - haven't entered some parts of the complex since riots in March 2015. She said they are routinely paid late and their watchtowers are so decrepit that some are unusable. There are no x-ray machines to scan visitors, and a machine used to check food is often broken.

Outnumbered and ill-equipped, Batista said, the guards can do little more than corral the prisoners into areas they themselves are afraid to enter.

Authorities acknowledge that Alcacuz is beyond saving. Rio Grande do Norte state Gov. Robinson Faria has announced it will close, though only after three new prisons are ready. In the meantime, an emergency force of corrections agents has been sent in to establish order and repair the damaged facility.

Even before the Jan. 14 riot, inmates spilled out of cells whose doors had been destroyed, often scavenged to make homemade knives. Guards merely locked the cell blocks, which they rarely entered except for occasional almost militaristic raids.

After the riot, guards pulled back even farther, allowing prisoners to roam the entire facility unchecked, with security forces merely ensuring they didn't escape and occasionally breaking up fights. They were unable to enter even to rescue those wounded in fighting, instead lowering stretchers from outside.

Cell blocks are divided up by gang affiliation as is typical in Brazilian prisons, with a handful of prisoners standing guard each night to ensure rivals don't attack inmates sleeping on the floors or nearby patios.

Prisoners complained to the AP that they don't have regular access to legal assistance or medical care. According to relatives, some inmates with knife and even gunshot wounds from the most recent fighting have not been treated.

Basic services may not be available at Alcacuz, but nearly everything else is: Police have seized cellphones, drugs, knives, handguns and several types of ammunition at the facility, which is built on sand soft enough to dig by hand.

At least four tunnels have been found, popping up just beyond the lightly patrolled walls.

"Here, we have everything, even dogs," one prisoner, who is serving a sentence for robbery, boasted via the WhatsApp messaging service. Like all of the prisoners interviewed, he refused to be named.

During the unrest, more than 50 prisoners also fled the facility, which neighbours refer to as the "Penitentiary of Maximum Escape."

Life in some Brazilian prisons, including Alcacuz, got even worse this year when fights between gangs led to a series of gruesome murders.

As guards watched last month, a member of the Crime Syndicate of Rio Grande do Norte barbecued body parts of a slain rival and ate the flesh, according to Batista, the union leader.

That kind of violence and the grisly killings seen in January go beyond the typical problems in Brazil's prisons and could signal the beginning of a nationwide gang war for control of the system, said Benjamin Lessing, a political scientist at the University of Chicago who studies criminal conflict in Latin America.

The First Capital Command, the country's largest criminal organization, has picked fights with several gangs as it tries to expand its reach outside its traditional base in Sao Paulo. At Alcacuz, the First Capital Command is fighting the Crime Syndicate for control.

Brazil incarcerates more than 620,000 people in a system that has space for a little over 370,000, according to a 2014 Ministry of Justice report. Forty per cent of detainees are merely awaiting trial.

There aren't enough public defenders, and cases languish for years. The stiffening of penalties for drug offences and campaigns to crack down on crime have sent even more offenders into the prison system.

In response to the crisis, President Michel Temer's government has promised around 30 new prisons. But the new facilities would make space for about 25,000 more inmates, plugging only 10 per cent of the deficit reported in 2014.

"More prisons means more prisoners and stronger gangs," said Karina Biondi, author of "Sharing this Walk: An Ethnography of Prison Life and the PCC in Brazil." "The solution, in my view, is less prison."

-----

Associated Press writer Renata Brito reported this story in Natal and AP writer Sarah DiLorenzo reported from Sao Paulo.