Updated

Brazil's most powerful criminal gang, First Command, is exploiting overcrowding and squalid conditions in the country's penitentiaries to expand its reach across the national prison system, an incursion at the center of massacres that have left nearly 100 inmates dead in the new year.

Some prisoners were beheaded or had their hearts and intestines ripped out in two recent prison massacres in northern Brazil, one launched by inmate members of the First Command and the other directed against them by a rival gang trying to stop the expansion.

Legal and security experts say the government's failure to improve conditions that make Brazil's prisons seem more like dungeons has only strengthened the First Command, based in the southern city of Sao Paulo and known by the Portuguese acronym PCC.

"The state has lost control over prisons," said Claudio Lamachia, who has visited many penitentiaries as chairman of Brazil's bar association.

Inside the lockups, survival often depends on gang protection and financial help. A slow legal system means a large percentage of prisoners wait years for their cases are heard. Meanwhile, First Command recruits new members, orders hits on rivals and runs drug-trafficking operations both inside and outside prisons even though many of its leaders are in maximum security penitentiaries in Sao Paulo state.

"Death is often the only alternative for an inmate who doesn't want to cooperate with gangs like PCC," said Lamachia.

The recent string of violence began on Jan. 1-2, when 56 inmates were killed in the northern state of Amazonas. Authorities said that the Family of the North gang targeted PCC members in a clash over control of drug-trafficking routes in northern states. It's not yet known how many died from each gang, but many of those killed were beheaded and dismembered.

Then on Jan. 6, in the neighboring state of Roraima, 33 prisoners were killed, many with their hearts and intestines ripped out. Uziel Castro, Roraima state's security secretary, said First Command members instigated the bloodshed against other prisoners for motives not entirely clear.

"There was no confrontation; this was a killing spree. It was barbaric," said Castro, adding that the Agricultural Penitentiary of Monte Cristo was built for 700 prisoners but housed 1,500.

Between Jan.2-9, another 10 inmates were killed in smaller prison clashes in Amazonas and the northeastern state of Paraiba.

On Monday, the federal government sent 200 soldiers to prisons in Amazonas and Roraima states. Several other states have requested similar help.

President Michel Temer, who was criticized for a slow response and calling the first massacre "a terrible accident," has since announced plans to build five new prisons. But Temer has not provided details, and it could take years to build new facilities.

"The penitentiary system has been in crisis a long time and gotten worse in the last 10 years," Justice Minister Alexandre de Moraes said recently, noting there has been a lack of investment amid a ballooning prisoner population.

Brazil had 233,000 prisoners in 2000, compared to 622,000 in 2014, according to Ministry of Justice data. The prisons combined were built to house roughly half that current number.

First Command was founded after a 1992 riot-turned-massacre when heavily military police stormed a prison, killing at least 111. Since then, the gang's rise has paralleled a deteriorating prison system.

Police investigators say the gang controls Rio de Janeiro's largest slum even though the city is home to the rival gang Red Command. Called "the party" by its members, First Command also has operations in Paraguay, Bolivia and Peru, according to Brazilian federal authorities.

Journalists are rarely given access to prisons, but photos and video shot with inmates' cellular phones show cells so packed there is little room to move around. Toilets and showers are filthy. There are often infestations of scorpions, poisonous centipedes and rats in the tropical heat.

Recent transfers of prisoners to avoid more riots have exacerbated bad living conditions inside the lockups, making it more difficult for inmates to get medical care, said Marlon Barcellos, legal coordinator for prisoner representation in Rio de Janeiro state. He gave the example of a prisoner who had trouble changing his colostomy bag after a recent transfer.

"The situation is desperate," said Barcellos. "There hasn't been a recent uprising (in Rio state), but the conditions for riots are there."

Contributing to overcrowding is a justice system that often essentially locks people up and throws away the key even before a trial is held.

Ivar Hartmann, a law professor at Fundacao Getulio Vargas, a think tank in Rio de Janeiro, says a study he conducted found that 40 percent of inmates have not been convicted, waiting sometimes years for even non-violent crimes to be processed.

And while they bide their time, they must figure out how to survive.

"The newbies feed the gangs like PCC in exchange for protection," said Hartmann. "That's one of the reasons why Brazil has a failed system."

___

Follow Peter Prengaman on Twitter: http://www.twitter.com/peterprengaman ; Follow Mauricio Savarese on Twitter: http://www.twitter.com/MSavarese .