By Leonardo Benassatto

FORTALEZA, Brazil (Reuters) - Criminal gangs on a rampage in northeast Brazil are posing an early security test for new far-right President Jair Bolsonaro, highlighting the challenge he faces in quelling drug-related violence and halting a record wave of murders in the country.

The state of Ceará has been rocked by five nights of attacks including a bomb that exploded under a highway, torched buses and assaults against banks and police barracks.

Security officials believe the attacks were triggered by the new state government's plan to undercut the power of gangs by sending prisoners to whatever jails have space to take them in, ending a longstanding practice of separating them according to gang affiliation.

The attacks, which prompted Brazil's new Justice Minister Sergio Moro to dispatch 406 federal security agents to Ceará, followed the Jan. 1 inauguration of Bolsonaro, who has made no secret of his admiration for the military dictatorship that ruled Brazil from 1964-1985.

The former army captain – who ran on a law-and-order platform - won support from Brazilians tired of the warring drug gangs that have come to terrorize large swaths of the country.

His task now is to make good on promises to design a coherent federal security strategy and end the wave of violence that saddled Latin America's largest nation with a record 63,880 murders in 2017. The murder tally last year is still unknown.

In Ceará's state capital Fortaleza, residents returned to the streets on Monday, making their way to work warily.

"The situation is tense," said taxi driver Weverton Barbosa. "We're scared, because we don't know what's coming, and it could get worse."

Ceará's public security and defense ministry said on Monday 148 people had been arrested for their alleged role in the attacks. In a statement on Sunday, it said at least three suspected gang members had been killed in gun battles with police.

Speaking last Friday, Bolsonaro, 63, praised Moro for quickly sending federal forces into Ceará to try and ease the situation.

But despite promising a tough stance on gangs, which profit from drug trafficking and often carry out mass attacks to spread fear and in response to police crackdowns in prisons or on the streets, Bolsonaro has provided few specific details about how he will bring them to heel.

At a press conference after his election, Bolsonaro urged prosecutors to follow the money to hobble prison gangs, such as Sao Paulo's powerful First Capital Command and Rio de Janeiro's Red Command.

"Let's fight organized crime and work to stop inmates from continuing to control their foot-soldiers from within prisons," Bolsonaro tweeted on in October, shortly after his first-round election victory.

On Friday, Bolsonaro asked lawmakers to quickly pass a bill to provide police and soldiers freedom from prosecution when on active duty, warning that sky-high violence would only slow if laws were passed to give security officials a free hand as they combat gang violence.

Last week, after being sworn in as justice minister, Moro said he would present an anti-crime bill within weeks, pledging to isolate the jailed leaders of drug gangs, which he called a threat to democracy.

Brazil's constitution mandates that public security is managed by state governments, and Bolsonaro may be limited in what he can achieve to restore calm from the federal level.

Ignacio Cano, a security expert at the Rio de Janeiro State University, said that given the high levels of violence in the northeast of the country, and the inability of state governments to cope with it, federal interventions such as the one in Ceará may become more prevalent under Bolsonaro.

"I think this mechanism is something they will end up using a lot more than they expect," he said.

He added that gang crime posed a new challenge for Moro, who made his name as a crusading anti-graft judge, jailing scores of Brazil's corrupt political and business elite as part of the country's notorious "Car Wash" probe.

"Moro's experience is in investigating white-collar crime, and now he will have to face a new, more violent type of criminal," he said.

(Writing by Gabriel Stargardter; Editing by Tom Brown)