Antonio Carlos da Silva was returning home to the Lagoa Redonda district of Fortaleza when two armed men drove past in a black car, ordering businesses to shut and residents to go inside and turn off the lights. Da Silva spent the next day indoors with no drinking water as a wave of unrest engulfed the north-eastern Brazilian city.

“There’s a climate of panic and people are terrified to go out. It’s like you’re a prisoner in your home and even then not safe,” says Da Silva. “These attacks are worse than in the past; they’re attacking shopping centres, bridges. No one knows how it will end.”

Now in its third week, the wave of bomb and fire attacks on bridges, banks and other infrastructure across Ceará state shows no sign of letting up, with two bridges blown up and a school bus set on fire during at least eight attacks on Sunday.

It is seen not just as a direct challenge to the new president, Jair Bolsonaro, but also as stark evidence that Brazil urgently needs penal reform and alternatives to the tough-on-crime policies he is promising.

“This crisis was entirely predictable. This is the fourth year we’ve had such attacks. We were sitting on a barrel of gunpowder and it just needed someone to light the fuse,” says Renato Roseno, congressman for the Socialism and Liberty party (PSOL), adding that poverty, “medieval prisons”, the war on drugs, and non-existent policies for marginalised young people make the state “fertile recruiting ground” for criminal gangs.

This time the fuse was lit by an announcement on 1 January from Ceará’s new secretary of penitentiary administration, Luís Mauro Albuquerque, that he didn’t “recognise” different criminal factions in the prison system and would end the practice of dividing them based on gang allegiances, as part of new hardline measures.

Vehicles burn in the street after attacks in the city of Fortaleza. Photograph: Alex Gomes/AP

The ensuing backlash has seen more than 180 attacks on public property as two of Brazil’s largest gangs, the First Capital Command (PCC) and Red Command (CV), operate a pact against the “common enemy” – the state. Reports say local rivals the Guardians of the State (GDE) and Family of the North (FDN), from Amazonas, have joined in – potentially setting up a dangerous wider alliance against authorities. Fortaleza, the state capital, has seen the worst unrest.

O Povo news site reported that gangs were paying young people in poorer areas to commit crimes, with 1,000 reais (£210) to set fire to a bus and 5,000 reais for “a fire of great proportions”. Others are settling personal drug debts with acts of violence.

Four hundred national guard have been sent to Fortaleza to restore order, the graduation of military police recruits has been speeded up and prisoners suspected of leading the unrest have been transferred out of the state. Police have taken more than 400 mobile phones from prisoners across Ceará, and there have been 358 arrests.

But, say critics, none of this will solve the structural crisis in Ceará’s overcrowded prisons, where the insistence on criminalisation and mass incarceration have left around 29,000 inmates occupying spaces for about 11,000 people. Overcrowding makes it harder to uphold even basic rights for inmates, handing control to gangs. These gangs then feed a crime epidemic among young people who lack alternatives.

“We haven’t changed the prison policy for 30 years, and we just repeat the same mistakes,” says Roseno, who heads a campaign to stop murders of adolescents. “The government needs a policy of penal reform but it doesn’t have one. A prison should aim to [reintegrate] the criminal into society, but only 5% of inmates are studying and only 7% are working – they need skills and education.”

Without investment and reform of the prison system, the cycle of violence and crime continues. “It is right for the state to re-engage with command of the prisons but [Albuquerque] made a mistake by saying he would not respect gangs without [having] a plan.”

Criminologist Sacha Darke, author of a new book on Brazilian prisons, points out that Brazil’s gangs originated in jails as inmates banded together for protection, and the practice of housing inmates with the local faction was started to stop them killing each other. “It is hard to see how they could run prisons without this system since prisoners protect each other, and there are far too few staff. Guards don’t even go into cells so it would be an absolute nightmare to throw all [the inmates] in together.”

As well as providing more staff and resources for prisons, judicial practice must change in order to reduce mass incarceration, he says. Despite a law in 2006 decriminalising possession of a small amount of drugs for personal consumption, “they began prosecuting anyone found with drugs, [even] a small quantity at home, as if they were serious traffickers”.

Technicians work on the site where a power transmission tower was damaged by a bomb on the outskirts of Fortaleza. Photograph: Paulo Whitaker/Reuters

This has contributed to a sharp rise in Brazil’s prison population to 700,489 – the world’s third largest. Of all inmates nationwide, 34.2% are on remand and Ceará holds the record for most prisoners who have not been convicted of a crime.

As drug gangs have migrated from Rio de Janeiro and São Paulo to a region offering an easy route to Europe, Ceará has become one of the most violent states in a country that in 2017 broke its own record for homicides. But, say critics, authorities haven’t taken this seriously enough or come up with smart, innovative policies to counter it.

The current crisis is now a perfect storm as gang leaders in overstuffed jails prey on young people with “no exit door from gangs”, says Roseno, while Ceará’s governor, Camilo Santana, from the leftwing Workers’ Party (PT), is “worried about not looking weak”. So far the response of Santana has echoed the tough rhetoric of Bolsonaro, calling for military reinforcements and promising stern action in his Facebook posts.

Meanwhile, the unrest has spread to 40 cities and on the streets of Fortaleza, there is little sign that either side is ready to back down. Local media have shown graffiti in Fortaleza with the warning: “We will not stop until Albuquerque quits.”

Da Silva, a social worker with young people at risk of joining gangs, says many areas are now too dangerous for him and co-workers to enter. “The authorities cannot step back for fear of looking weak, but this is going to lead to more serious problems,” Da Silva says. “Where is the intelligent response to these problems in Brazil? We have a super-ministry of security but where’s the super-ministry of education?”

Luiz Fábio Paiva, a sociologist at the federal university of Ceará and researcher with the Laboratory for the Study of Violence (LEV), says the assertions from the state government, which is “preoccupied excessively with manifesting and demonstrating a hyper-masculine show of fighting violence with violence”, are reckless.

“It’s irresponsible to put these [factions] in the same prisons. You are going to have to deal with the burden of deaths that already happen and are going to increase,” he says.

Roseno says: “The question is: how can we reduce the power of the gangs? How can we not just get rid of the weapons and cut off financial resources but offer young people a different life? These gangs operate by offering a sense of brotherhood, self-esteem, money. They are filling the space where there are no public policies.”