The largest bloodbath appeared to be an orchestrated mass killing targeting members of Brazil's biggest gang
But experts see method in last week's madness.
They say it was part of a war between organized drug gangs in one of the world's most important cocaine markets and trafficking routes.
Last week's series of massacres left 100 prisoners dead -- many of them active members of gangs, authorities said. The government has deployed 200 emergency personnel to secure the two prisons where the most blood was shed.
The largest bloodbath appeared to be an orchestrated mass killing targeting members of Brazil's biggest gang, the First Capital Command (PCC).
It was thought to be a backlash by the PCC's rivals for its violent expansion.
Authorities say the Sao Paulo-based PCC seized control of the country's southern supply routes last year by gunning down powerful drug trafficker Jorge Rafaat.
Its expansion has made it an outright enemy of the second-biggest Brazilian gang, the Red Command (CV), based in Rio de Janeiro.
After the Rafaat killing gave it control of a key Paraguayan border route, the PCC then turned its attention to securing control of the north.
"What it wants is to dominate the whole of Brazil," said Marcio Sergio Christino, a public prosecutor of organized crime.
"The Red Command used to use southern trafficking routes that are now controlled by the PCC," said Christino.
After the killing, the Red Command "had to look for alternative routes in the north," he said.
There it joined forces with the third most-powerful faction in Brazil, Family of the North (FDN), "to forge an alternative route to the one used by the PCC."
Authorities said FDN members were the ones who beheaded and mutilated PCC members in the biggest of last week's massacres, in a jail in the northern state of Amazonas that left 60 people dead.
With an estimated 20,000 members, the PCC thrives even with its leader Marcos Willians Herbas Camacho, known as "Marcola," behind bars since 1999.
Investigators say that apart from its drug-trafficking activities it also owns bus companies, minor football clubs and an illicit petrol refinery.
"The PCC is a very solid and hierarchical organization," said Sergio Adorno, an expert on violent crime at Sao Paulo University.
"It has very clearly defined rules and a clear division of tasks and functions."
Its rival Red Command is considered Brazil's oldest gang, dating to the 1970s.
It thrived on a cocaine boom from the 1980s, expanding from bank robberies and kidnapping to control the drug trade in Rio.
But its power has declined, said Alexander Araujo, a federal prosecutor in the city. He says CV is less organized and ambitious than its main rival.
Araujo told AFP he believes the root cause of the conflict is the PCC's encroachment on CV's turf in the Rio slums with the help of smaller local gangs.
That makes Brazil a major stepping stone for networks trafficking the drug via Africa to Europe.
Experts say Brazilian traffickers are aiming to forge ties with Colombian gangs to offer them access to one of the most important international drug routes in the world.
But first they have to win the turf war at home.