Brasília (Reuters): Drug gangs sparked a prison riot that killed 56 people, with decapitated bodies thrown over prison walls in the bloodiest violence in more than two decades in Brazil's overcrowded penitentiary system, officials said.

Sergio Fontes, the security chief for Amazonas state, told reporters several decapitated bodies were thrown over the wall of the prison in the Amazon city of Manaus, with most of those killed coming from the Sao Paulo-based First Capital Command (PCC) drug gang.

"This was another chapter in the silent and ruthless war of drug trafficking," he said.

Justice Minister Alexandre de Moraes traveled to Manaus on Monday to meet Amazonas Governor José Melo Oliveira and other federal security officials about the riot.

Pedro Florencio, the Amazonas state prison secretary, said the massacre was a "revenge killing" in a feud between criminal gangs in Brazil.

The violence began late Sunday and was brought under control by around 7 a.m. AMT (1100 GMT) on Monday, Fontes said.

Just as the riot began in one unit of the Anisio Jobim prison complex, dozens of prisoners in the second unit started a mass escape in what authorities said was a coordinated effort to distract guards.

Overcrowding is extremely common in Brazil's prisons, which suffer endemic violence and what rights groups call medieval conditions with food scarce and cells so packed that prisoners have no space to lie down. The Anisio Jobim prison complex currently houses 2,230 inmates despite having a capacity of only 590.

Hours after the Anisio Jobim prison revolt ended, prisoners at an adjoining detention center began a riot and attempted to escape. Authorities said the situation was quickly brought under control.