Riots have broken out in 18 prisons in the Brazilian state of Sao Paulo after a wave of attacks on the streets left at least 30 people dead.
State officials said the riots were organised by the same criminal faction - the First Command of the Capital (PCC) - that carried out the attacks.
About 100 people have been taken hostage by prison inmates.
Armed criminals targeted officers in 55 attacks in the early hours of Saturday. Nineteen of the dead were policemen.
The state governor insisted Sao Paulo would not bow to organised crime.
The incident thought to have sparked the attacks was Friday's transfer of about 600 prisoners to a maximum security unit.
It was organised to try to counter a co-ordinated rebellion planned by the PCC for the weekend in a number of prisons in Sao Paulo state.
PCC leaders were being questioned on the subject when the attacks started on Friday night, targeting officers in police stations, mobile units, at their homes or in bars.
The assailants used machine-guns and grenades. In one incident a home-made bomb was thrown into a police station.
As well as in the city of Sao Paulo, the attacks took place in the suburbs of Osasco, Guarulhos and Carapicuiba, and in the coastal cities of Cubatao and Guaruja.
In addition to the dead, at least 15 policemen and 15 attackers were wounded and 16 attackers arrested, police said.
The attacks sparked revolts in more than 20 state jails.
Sao Paulo state prison affairs secretary Nagashi Furukawa said the PCC was behind the rebellions but added: "Most of these uprisings are minor, and none of the facilities have been destroyed."
A spokesman for Mr Furukawa later said: "As far as we can tell none of the hostages has been hurt or seriously threatened."
The BBC's Steve Kingstone in Sao Paulo says the state is accustomed to violent crime, but not on this scale.
Denis Mizne of the Instituto Sou da Paz, which works to improve Brazilian policing, said: "You are living in a city and you wake up seeing that police officers... were attacked at the same time by an organised group.
"If the state is being attacked, what can happen with every normal citizen. That's what everybody thinks."
Police officials said they would not be intimidated.
"The police will not retreat from these attacks," Sao Paulo State Security Secretary Saulo de Castro Abreu Filho told local TV.
"They have struck at the spinal cord... of our security."
Founded in 1993, the PCC has been involved in drugs and arms trafficking, kidnappings, bank robberies, and prison breaks and rebellions, police say.
In November 2003, the gang attacked more than 50 police stations, killing three police officers and wounding 12.
Those attacks were thought to have been orchestrated by PCC leaders in jail.