Rioting inmates decapitated their rivals in brutal fighting between two gangs in a Brazilian jail that left 56 dead, while 144 prisoners escaped, officials said. The riot broke out Sunday afternoon and lasted through the night at a prison on the outskirts of Manaus, the capital of Amazonas state, state public security secretary Sergio Fontes said. Bloodied and burned bodies were stacked in a concrete prison yard and piled in carts, an AFP photographer at the scene said. Fontes's department later lowered the death toll to 56 from an earlier count of 60. The fighting ranks among the most deadly of numerous prison riots across Latin America in the past decade. Fontes called it "the biggest massacre" ever committed at a prison in the state. Outside, heavily armed police hunted for dozens of inmates who escaped through a series of tunnels discovered at the Anisio Jobim penitentiary complex. Fontes's department later said that 112 prisoners escaped from that prison and another 72 from the nearby Antonio Trindade Penal Institute. Just 40 of the escapees were captured, it added. - Decapitations - Police finally restored order at the prison on Monday morning, freeing 12 guards who had been taken hostage, Fontes said. They found a horrific scene inside. "Many (victims) were decapitated, and they all suffered a lot of violence," he told a news conference. He said the gruesome scene appeared aimed at sending a message from the Family of the North (FDN), a powerful local gang, to rivals from the First Capital Command (PCC), one of Brazil's largest gangs. The PCC's base is in Sao Paulo, some 2,700 kilometers (1,650 miles) to the southeast. "During the negotiations (to end the riot), the prisoners had almost no demands," Fontes told local radio network Tiradentes. "We think they had already done what they wanted: kill members of the rival organization." - 'Silent war' - It was the latest eruption of horrific violence to hit Brazil's underfunded and overcrowded prisons. In October, deadly riots broke out at three prisons, blamed on fighting between members of the country's two largest gangs, the PCC and the Red Command (CV). During that episode, rioting inmates took visitors hostage, beheaded rivals and burned others alive, killing 33 people in all, the authorities said. In 1992, a riot in Sao Paulo's Carandiru prison left 111 people dead. Brazil's prisons are often controlled by drug gangs, whose turf wars on the outside are also fought out among inmates. "There is a silent war of drug trafficking, and the state needs to intervene," Fontes said. "What did we see in this case? One faction fighting another because each wants more money. The fight is for money and space." Brazil has struggled for years against a lucrative and violent drug trade. But jailing drug traffickers has done little to solve the problem. It may even fuel it, critics say. - Overcrowding - Human rights groups have long complained about the conditions in Brazilian prisons. "The problem starts with overcrowding," lawyer and activist Marcos Fuchs said. "When you put inmates from rival factions in the same prison unit, the state has no control over what happens inside." Some 622,000 people were imprisoned in Brazil as of the end of 2014, most of them black males, according to a justice ministry report. That makes it the world's fourth-largest prison population, the report said, after the United States, China and Russia. Brazil's prisons need 50 percent more capacity to handle the current number of inmates, the justice ministry report found. There were 1.67 prisoners for every available space, it said. In Amazonas state, the figure was 2.59 prisoners for every space.