RIO DE JANEIRO - Fighting among inmates touched off a riot at a prison in the northern state of Amazonas, leaving at least 56 dead, including several who were beheaded or dismembered in the worst bloodshed at a Brazilian prison since 1992.

Authorities said the riot apparently grew out of a fight between two of the country's biggest crime gangs over control of prisons and drug routes in northern Brazil. Amazonas authorities initially reported 60 dead, but Monday afternoon the state public security secretary's office reduced that figure to 56.

State public security secretary Sergio Fontes said some inmates escaped from the Anisio Jobim Penitentiary Complex in Manaus during the riot, but he did not say how many. He said 40 had been recaptured.

Manaus, Brazil Manaus, Brazil Manaus, Brazil

There were 1,224 inmates in the prison, which was built to hold 592, Fontes said. The prison is run by a private company that is paid according to the number of inmates.

Twelve prison guards were held hostage by the inmates, though none was wounded during the riot that began Sunday afternoon and ended Monday morning.

“This is the biggest prison massacre in our state's history,” Fontes said at a news conference. “What happened here is another chapter of the war that narcos are waging on this country and it shows that this problem cannot be tackled only by state governments.”

Fontes confirmed that many of the dead had been beheaded. Judge Luis Carlos Valois, who negotiated the end of the riot with inmates, said he saw many bodies that had been quartered.

Brazil Prison Killings Relatives of prisoners wait for information outside the Anisio Jobim Penitentiary Complex in Manaus, Brazil, Jan. 2, 2017. Relatives of prisoners wait for information outside the Anisio Jobim Penitentiary Complex in Manaus, Brazil, Jan. 2, 2017.

“I never saw anything like that in my life. All those bodies, the blood,” Valois wrote on Facebook.

It was the largest death toll during a Brazilian prison riot since the killing of 111 inmates by police officers in the Carandiru penitentiary in Sao Paulo in 1992. Police said they acted in self-defense then.

Two other prisons in Manaus also reported riots Monday. At one, 87 prisoners escaped, including an inmate who posted a picture of himself on Facebook as he left. Amazonas police were investigating whether there was a link between the violence at the three prisons.

By evening, Amazonas state police said the situation was stable in all three prisons.

Fontes said the inmates at Anisio Jobim made few demands to end the riot, saying that hinted at a killing spree organized by members of a local gang, the Family of the North, against those of the First Command of the Capital that is based in Sao Paulo.

Relatives of prisoners await news of the fate of t Relatives of prisoners await news of the fate of their loved ones, in front of the Medical Legal Institute, after a bloody prison riot in the Amazon jungle city of Manaus, Brazil, Jan. 2, 2017. Relatives of prisoners await news of the fate of their loved ones, in front of the Medical Legal Institute, after a bloody prison riot in the Amazon jungle city of Manaus, Brazil, Jan. 2, 2017.

The secretary said officers found a hole in a prison wall through which weapons entered the building. A policeman was wounded in exchange of gunfire with the inmates. Several firearms were found when police searched the prison after the riot.

Jose Vicente da Silva, a former national public security secretary, said the incidents in Manaus were a result of Brazil's severe recession and poor management of the prison system.

“Since 2014 homicides in prisons of Amazonas are double the national average, and last year they cut their public security budget by 50 percent due to austerity measures. This incident is a repetition in a bigger scale,” da Silva told The Associated Press. “Every year 500 inmates die in Brazilian prisons. With the current economic crisis and the budget cuts, the gangs get even bolder.”

The First Command, nationally known as PCC, is the most powerful drug and prison gang in Brazil and it has been trying to extend its reach to northern prisons dominated by the Family of the North. To counter, Family of the North associated with the Red Commando of Rio de Janeiro, the second biggest crime gang in Brazil.

Valois said that during the negotiations at Anisio Jobim, inmates asked only “that we did not transfer them, made sure they were not attacked and kept their visitation” rights.

The riot ended after the inmates freed the last of the 12 prison staffers they had held hostage, Valois said.