RIO DE JANEIRO — At a massive party put on by the Amigos dos Amigos gang a while back, dozens of teenagers wearing nothing but sandals, swim trunks and comically oversized assault rifles provided security.

Partygoers casually snorted cocaine off tables set up in the plaza at the Rocinha favela and waved guns in the air as they danced. If neighbors didn’t like the bass-heavy electronic music pumping until the early hours, they had little recourse: Rocinha was a Neverland-like world where boys were kings and the state was far, far away.


But the gang no longer calls the shots in Rio’s largest slum. Now the cops are in charge.

After half a century of shocking neglect, Rocinha is one of several sprawling Rio slums that have been retaken by the state. Although the Amigos and two other drug-trafficking gangs continue to control the majority of Rio’s nearly 1,000 favelas, the “pacified” slums are seeing development, investment and the decidedly mixed blessing of being run by Brazilian military police.


PHOTOS: Retaking the slums of Rio de Janeiro

Over four years, the government has established more than 25 pacification units, as favela-based police stations are called. Most of them have been set on valuable land near tourist destinations or otherwise iconic locations, in a process that some residents criticize as a Potemkin-like move in preparation for the soccer World Cup in 2014 and the Olympic Games in 2016.


These days, parts of Rocinha are on the map as a nightlife destination for the hip, who flock weekly to a high-class, closed-doors version of the kinds of parties the Amigos used to put on.

Months after the gangsters had their last bash, models and soap opera stars came to the favela for one of the hottest after-parties during Rio’s Fashion Week. They handed the keys to their luxury bulletproof cars to valets, gushed about the breathtaking views of the Atlantic and wondered about buying a place there.


Rocinha is an obvious candidate for property appreciation, or speculation, as the case may be.

Like most favelas, it sprang up in the middle of the 20th century as a flood of migrants from northeastern Brazil started to pour into the big cities in the southeast. They found low-paying jobs but no housing, so they set up makeshift settlements on hills or on the outskirts of the city and lived outside the official grid. Today, almost 30% of Brazilians live in favelas, many of them dominated by former left-wing politico-criminal groups that found an easy source of revenue in the drug trade.


Rocinha is built on a hill, with views that in the United States would make the site more valuable than that of the million-dollar apartments below. Some roads are paved, some are not, and even along those large enough for cars to pass, precarious brick-and-mortar structures sit between professionally done houses and restaurants. Throughout, huge tangles of wires from the days of do-it-yourself electricity grids hang over the narrow streets.

Middle-aged women shuffle up the winding roads with groceries, passing dimly lighted shops and restaurants whose owners call out happily to friends and relatives. Standing in front of squad cars with permanently flashing red lights, uniformed police with machine guns keep watch.


PHOTOS: Retaking the slums of Rio de Janeiro

Where residents once complained about the total absence of any government authority, they now decry police corruption and abuse, as well as an initiative seemingly driven more by real estate speculation and preparations for the World Cup and Olympics than a concern for residents. But most, including even some in drug gangs, agree that the makeover is worth trying.


Jose Junior is the head of AfroReggae, a favela-based cultural organization that works to remove youths from the gang life, and works closely with the government. He thinks the initiative may be Rio’s last, best chance to improve conditions.

“If this doesn’t work, if Rio doesn’t manage to change by 2016, I think it will take another 50 years to solve these problems,” he says.


***

Carlos Augusto Pereira still shakes his head over the thought that his temper almost got him killed.


“I came out here fairly late one night, and I saw a group of police yelling at some local kids and smacking them around,” he says, pointing out the window of his run-down office, where the 34-year-old teaches video techniques.

When the officers wouldn’t give him the number of their superiors, he marched off to the local station.


Soon, an officer called Miranda appeared.

“Who are you, and what are you doing here? Do you want to die?” he said.


A pistol soon appeared on a table, then another armed officer, and Pereira was told he was under arrest. He tried to get away but was put into the back of a squad car. Miranda got into another car and told Pereira’s driver to follow him up the hill.

“I thought, I can’t believe it. I’m going to die for some stupid thing I did because I was angry,” he says, remembering cases of residents executed by cops, their bodies later posed as armed criminals.


At first, the officers in Pereira’s car didn’t respond to his attempts to show how well connected he was in the community. But when Miranda took a turn up a dark, isolated hill, the driver said, “Ele esta maluco” (“He’s mad”) and turned back to the police station.

“I’m now facing a charge of disobedience,” Pereira says in disbelief.


When police aren’t overreacting, their presence can be so sporadic as to be ineffective, residents throughout Rio’s favelas say. Ironically, the presence of police has meant that many types of crime are arriving for the first time in the neighborhoods, where the traffickers used to keep tight order.

“We never had rape. We never had robbery. We never had small-time crime,” says Carlos Belo da Silva, 19, who is working on a career as a professional surfer. “If that kind of thing happened, the traffickers would find out who it was. They knew us. And then someone would have to pay, somehow or another, get beaten up. I know that’s wrong; no one has the right to dish out punishment like that, but it kept order.”


“I never used to lock my door,” says Davila Pontes, a student, butting into the conversation on a deck overlooking the ocean. “But now I do, because my neighbor’s house was broken into.”

There are glaringly obvious benefits to the presence of the state. In the small Pavao-Pavaozinho favela, a new, brightly lighted elevator tower next to a hill means that residents now live less than five minutes from the beaches of Ipanema, one of South America’s most expensive neighborhoods. All day long, kids jump on the elevator with their boogie boards, still wet and with sand on their feet.


“There are more opportunities now,” Belo da Silva says. “But the police now treat us like we are all suspects

Junior, of the AfroReggae group, acknowledges that that the government has brought many of its “vices” into his communities.


“If you go to any pacified favela,” he says, “the residents will complain about the police. And they should complain. But why weren’t they complaining before? They were afraid. Now they have the right to complain.”

***


In the Mandela favela recently, Marcelo Piloto, the leader of the Red Command gang there, remained the law in the slum. But he knew the life he was leading couldn’t last.

He was dressed like Tiger Woods — red Lacoste polo tucked into khaki slacks, sensible shoes — except for the large assault rifle resting on his chest and a belt adorned with pistols and ammunition. Unlike most of his foot soldiers, he is white.


“I escaped from prison, and this life allowed me to become something without having to go back to that horrible place,” he said, walking through the territory he controlled. The entrance to the favela was blockaded, and the streets hummed with kids on motorcycles with walkie-talkies, reporting on movements around the slum.

PHOTOS: Retaking the slums of Rio de Janeiro


Piloto had banned the sale of crack in the favela and was eager to emphasize that he avoided conflict and violence as much as possible.

“If we find out there is a rape in the community, that man has to die,” he said. “But sometimes we try to contact the family, try to find another solution, expel him from here forever instead.”


Piloto said he would give up the gang life if the government granted him amnesty.

“If there was a way out for, I’d hand this over tomorrow,” he said, grabbing the biggest gun with both hands, “and I know there’d be a flood of people behind me.”


Piloto didn’t know that Rio police had already decided to pacify his favela. Tanks rolled in last month and retook the area in 20 minutes. Piloto and others were warned and apparently fled.

Police are offering a reward worth thousands of dollars for information on Piloto. In the meantime, his favela begins the slow transition to life in normal Brazilian society.


Bevins is a special correspondent.