RIO DE JANEIRO, Brazil — With assault rifles in hand, black-uniformed special operations police blocked the entrance to one of their department’s own buildings here Monday, on orders from the city’s chief of civil police.

The ensuing standoff was as dramatic as a true crime noir.

The target of the raid was the state’s organized crime taskforce, called DRACO, whose own investigation had led, just two days earlier, to the arrest of dozens of police officers in a corruption probe circling close to the chief himself, Allan Turnowski.

Turnowski defended his investigation as the first step toward cleaning up Rio’s police. But by Tuesday Turnowski himself resigned from the force after a “long conversation” with his boss. The very public battle only underscored a seemingly intractable security problem, one the city must tackle as it prepares to host the next World Cup and Olympic games. Rio’s notorious police force needs an overhaul as extensive as the one it has promised to give its gang-controlled slums.

“These relationships between police, drug trafficking and organized crime have become a hallmark of these last 30 years in Rio,” said Jorge Barbosa, who works for Observatorio de Favelas, an aid organization that operates in the city’s slums. Tackling police corruption, he said, “is extremely important, as important as the fight against drug trafficking.”

Rio falls under the ambit of various civil, federal and military police agencies and each is playing a role in the city’s ongoing effort to wrench slums from the grip of violent gangs. Both sides are heavily armed and, in pursuing the fight, Rio’s police have come to rank among the deadliest in the world.

Police in Rio kill one person for every 23 they arrest, according to a 2009 Human Rights Watch report. In the United States, by contrast, the ratio of killings to arrests is one in 37,000.

What’s more, police corruption is widely believed to have buttressed the power of Rio’s drug gangs. Cops have been charged with selling traffickers weapons, protection and even tip-offs on the eve of police operations. The recurring accusations have contributed to a widespread perception that, especially for the city’s poor, an encounter with police can be as dangerous crossing paths with a criminal.

“There’s a climate of insecurity,” said Thereza Lobo with an urban-renewal non-profit called Rio Como Vamos. “People are as afraid of being approached by police as they are by anyone else.”

Fighting such perceptions, and the reality underlying them, has become a top priority for Rio officials. As the city prepares to host the World Cup in 2014 and the Olympics two years later, Rio’s leaders have been at pains to promise the world the city’s infamous violence is under control. Police will be the instrument necessary to deliver on that promise, but they also remain very much a part of the problem.

Perhaps no better example is just how thorny the latest push against corruption has become. In authorizing the Sunday raid on DRACO, chief Turnowski said he was pursuing allegations the organized crime unit had taken bribes in exchange for stopping investigations.

But just two days earlier, Turnowski had been forced to explain to federal investigators why his former right-hand man, Carlos Antonio Luiz Oliveira, had been arrested on charges of selling confiscated arms to drug dealers. Oliveira, who left the police force last year but remains on the city payroll, was caught up in a wide-ranging investigation called Operation Guillotine, which has put at least 30 active police officers in prison since Friday.

The timing of Turnowski’s counter-investigation struck many here as more than suspicious.

“It’s impossible to think this is a coincidence,” said Marcelo Freixo, a Rio de Janeiro state assemblyman. “The chief of police sees his ex-right hand man investigated and arrested, and one day later resolves to investigate the unit that did it.”

Adding to the intrigue, the head of the organized crime unit, Claudio Ferraz, has been named in the press as a possible candidate take over the job of — that’s right — chief of civil police, Allan Turnowski.

This fact has led one of Brazil’s most widely-read law enforcement experts, former national security director Luiz Eduardo Soares, to dismiss Turnowski’s investigation “a pathetic act of retaliation.”

Soares said the government’s decision of which side to support is key. “This investigation could be a watershed moment,” he said.

In a TV interview Monday on the Globo news network, Turnowski rejected any possibility he was carrying out a reprisal.

“Absolutely not,” he said. “This is the beginning of a long process to clean up the police. There are other units that are already the subject of inquiry, and others that will be. Because results without lisura won’t be allowed.”

The word he used, lisura, which connotes principles or honesty in Portuguese, was perhaps slyly chosen.

Just a day and a half earlier, Turnowski’s boss, Rio’s State Security Secretary Jose Beltrame said in a television interview he would judge police by both honesty and results. “It’s not enough to have results if you don’t have lisura,” Beltrame said.

In the press release Tuesday announcing Turnowski’s resignation, Beltrame praised Turnowski for his loyalty and dedication, and noted the reduction in crime during his tenure. The word lisura, however, appeared nowhere in the document.