TO MANY Brazilians, Sérgio Moro is a hero. The young judge oversees Lava Jato (“Car Wash”), the investigation of a vast bribery scheme centred on Petrobras, a state-controlled oil giant. The scandal shows how deeply corruption has penetrated the political and business establishment, especially the Workers’ Party (PT) of the president, Dilma Rousseff (who risks impeachment on grounds unrelated to the Petrobras scandal). Mr Moro’s unsparing pursuit of the suspects, many of them rich and powerful, is rightly celebrated as proof that Brazil can also uphold the rule of law. “We support Lava Jato,” reads a banner planted outside his federal courtroom in the southern city of Curitiba.

In all, 144 people have been charged with crimes including bribing Petrobras executives to secure billions of dollars’ worth of contracts. The oil men passed much of the illicit money on to politicians. The dozens of people who have been jailed pending trial include some of the biggest names in Brazilian business (though few prominent politicians). Among them are Marcelo Odebrecht, boss of Odebrecht, Brazil’s biggest construction firm, and André Esteves, who had been head of BTG Pactual, a big investment bank. Both deny wrongdoing.

Gratifying as it may be to see billionaires behind bars, some lawyers are troubled by Mr Moro’s penchant for locking up suspects before they go on trial. Most are loth to challenge a charismatic judge. Those who publicly object tend to work for one of the innumerable defence teams. All 11 directors of the comically named but serious Institute for the Defence of the Right to Defence are thus employed. Heloisa Estellita, a professor of criminal law at the Fundação Getulio Vargas Law School in São Paulo, is one of the few public critics of Mr Moro’s methods who is independent. She thinks he has wrongly “used pre-trial detention to extract plea bargains”.

The problem is not confined to plutocrats caught up in Lava Jato. Roughly two-fifths of Brazil’s 600,000 prison inmates are awaiting trial. This mass incarceration of people presumed innocent is a sign of something amiss with Brazil’s criminal-justice system, which is based on an antiquated penal code (from 1940) and falls short in many respects of international norms. Although some of its quirks work against defendants, others act perversely in their favour.

Mr Odebrecht’s counsel hired lawyers from Blackstone, a barristers’ chambers in London, to assess whether the conduct of Lava Jato complies with international standards. Its report says that Mr Moro’s use of pre-trial detention may raise “serious issues” and violate conventions to which Brazil has signed up. Acknowledging liberty as a basic right, most countries use pre-trial detention as a last resort, to prevent suspects from fleeing, meddling with an investigation or committing more crimes.

That is the justification for jailing Mr Esteves, who along with a prominent PT senator, Delcídio do Amaral, was charged with urging another Petrobras suspect to flee rather than co-operate with investigators. Because Mr do Amaral enjoys parliamentary privilege, the Supreme Court, not Mr Moro, ordered his confinement and that of Mr Esteves. Mr do Amaral also denies wrongdoing.

The grounds for locking up Mr Odebrecht and other Petrobras defendants are less obvious. Brazilian law allows judges to order pre-trial detention as a way to maintain “public and economic order”, a justification often invoked by Mr Moro—as in Mr Odebrecht’s case. He argues that the suspects have the money and the political clout to interfere with the investigation. The detention of Mr Odebrecht is “an exceptional measure”, he admits, but “this is an exceptional case”.

Perhaps not as exceptional as the judge contends. The Blackstone brief argues that most suspects can safely be released on bail; house arrest or electronic bracelets can stop them from fleeing. Pre-trial detention should not be used to browbeat them into co-operating with investigations or to signal the gravity of the charges they face. The Lava Jato inquisitors deny they are doing this, but readers of Blackstone’s report will wonder. Timothy Otty, its lead author, has written human-rights opinions on behalf of Abdullah Ocalan, a Kurdish separatist leader, and detainees at the American prison in Guantánamo Bay. “Just as it was wrong to jettison the protection of liberty and right to fair trial as part of the war on terror, so it would be wrong in the fight against corruption,” says Mr Otty.

Waxing and waning: Brazil's economic woes, in charts Brazil’s high courts have taken a similar view. In at least ten habeas corpus petitions arising from Lava Jato the Supreme Court has freed suspects, often on the grounds that Mr Moro had jailed them for “generic and abstract motives”. A court could soon free Mr Odebrecht for the same reason. Last week a judge on Brazil’s second-highest court said he should be released and monitored with less draconian measures. If Mr Moro is acting high-handedly, that is because Brazilian law confers unusual power on judges. In addition to overseeing the investigation of suspects such as Mr Odebrecht, he will single-handedly try the case, render a verdict and hand down a sentence, all without reference to a jury. These multiple roles can give rise to a conflict of interest: an investigating judge may be reluctant to acquit a suspect he has jailed. The answer to this “schizophrenic” situation is to split the roles of investigating a case and trying it, as is the practice in France and Italy, says Fernando Mendes of the Association of Federal Judges. He also favours a more demanding standard for locking suspects up than keeping order.

Tender traps

But the law can be as weirdly indulgent as it is harsh. Alongside mayors, priests, policemen and many others, university graduates are entitled to pre-trial imprisonment in “special” (ie, relatively comfy) conditions. Mr Odebrecht, a graduate of the Federal University of Bahia, spent his first month in custody in a windowless cell in a federal police station but was then moved to a prison hospital, where his hypoglycaemia can be monitored.

If convicted, he could be set free, at least for a while. That is because convicts are entitled to go home while they exhaust their appeals. In one notorious case Antonio Pimenta Neves, a journalist who killed his lover in 2000, confessed and was released on bail six months later. He was sentenced in 2006 and began doing time in 2011, after the Supreme Court upheld his conviction. Mr Odebrecht’s high-powered lawyers could keep him out of jail for years.

Many critics of the system, including Mr Moro, think convicts should have to file appeals from their jail cells. That would make sense. So would an overhaul of the criminal code which left at liberty people presumed innocent and guaranteed them a fair trial. Mr Moro is right to uphold the law, but the law itself needs to change.