Updated

Five years ago, Rio de Janeiro's "favela" hillside slums had such a bad rap that they were virtual no-go zones, where drug lords laid down the law and outsiders set foot at their peril.

But since 2011, police have seized control of dozens of favelas from drug gangs, and things have changed so dramatically that some of the slums are now seen as hot real estate investments — so hot, in fact, that two Europeans recently locked horns in a legal battle over a battered favela house.

Rio's slum "pacification" program is part of a strategy to make the city safe ahead of the 2014 soccer World Cup and 2016 Olympics. Murder rates are down, and SecoviRio, an organization representing Rio's real estate professionals, estimates that in the 72 hours after police took the first three favelas, property prices there jumped by 50 percent — and are still climbing.

In the Vidigal slum, middle-class Brazilians and foreigners who can't afford chic Rio neighborhoods are snapping up properties wedged between tony beachfront areas like Copacabana and Ipanema.

"It used to be you'd say the word 'favela' and people would instantly think: drug trafficking, machine guns, grenades, kidnappings," said Anderson Ramos, a real estate agent with V.D.G. Imobiliaria, Vidigal's first real estate agency. "But now, you say 'favela' and they think pacification and good deals on houses."

"We're seeing upper-class people, millionaires, famous musicians practically queuing up."

Andreas Wielend, one of the two Europeans fighting over a Vidigal property, got a killer deal when he bought an abandoned cinderblock house from a German businessman in late 2009. The deal was so sweet the owner had seller's remorse. When Wielend was away on vacation last fall, the former owner took over the house and changed the locks.

"It was unbelievable," Wielend said. "This house was my baby, I worked so hard to renovate it, and then I'm kicked out on false pretenses. It was surreal."

The sparring foreigners are part of growing group of wealthy buyers keen on acquiring ocean-view properties in Vidigal that are seen as bargains in a city whose real estate prices are among the highest in the Americas.

"I hate to use the word fashion, but the favelas are in fashion, for the first time," said Leonardo Schneider, SecoviRio's vice president.

Built in the late 19th century by army veterans seeking affordable housing, the first favelas sprang up unplanned, and many still lack basic services like sewage connections and electricity. For generations, they were home to destitute migrants, and in the 1970s began falling under the control of ruthless drug gangs.

When Wielend bought his place, it had long been abandoned and lacked a bathroom, kitchen and even doors. But it had a breathtaking view over Rio's concrete jungle and the Atlantic Ocean. The German seller, who had snapped up dozens of properties in Vidigal, was asking for just 20,000 reals, or $10,000.

Still, with a gang capo and his heavily armed minions for neighbors, Wielend thought hard before buying.

"It was a bit like signing up to living in 'Robinson Crusoe,' on a remote island where everything's sort of makeshift," said the 35-year-old, a telecommunications engineer who first came to Brazil with Siemens, the German electronics giant. "I thought of the investment as a big gamble."

Then came the big change. Hundreds of police stormed into Vidigal, pushing out the drug gang and establishing a permanent presence. To date, 28 police pacification units have been established over dozens of favelas, with 12 more units expected this year.

Studies show homicides are down by double digits. A luxury boutique hotel with a rooftop pool is going up in Vidigal, and Italian tire-maker Pirelli shot part of its 2013 pinup calendar in Dona Marta, which in 2008 was the first favela to be pacified.

The Federal Reserve Bank of New York reckons that 15 percent of the 168 percent rise in Rio property prices between January 2008 and March 2012 was directly attributable to pacification and the resulting drop in crime.

Ramos, the agent, said he recently closed a slew of $25,000 deals on small cinderblock homes that wouldn't have fetched $5,000 a few years ago.

"People here have understood that favelas are a hot thing, and a lot of people are eager to cash in," said Ramos. "And for a guy here, who for the price of his tiny studio apartment in Vidigal he can buy a big, three-bedroom house with a garage and a patio in another area of Rio, it's like a dream come true."

Not everyone sees the situation in such a rosy light. Many voice worries that the poor could be priced out of the slums as their cost of living rises and developers pressure them to sell.

SecoviRio's Schneider acknowledged that the city's demographics may change. About a quarter of Rio's 6 million people live in the 1,071 favelas.

"In the coming 10-15 years, rich people are going to be buying houses and developers are going to be building condominiums in certain favelas that are well located, with views," said Schneider. "Naturally, the poor people will move to another area and certain favelas, like Vidigal, are going to be transformed into luxury neighborhoods."

Wielend, meanwhile, won a court ruling ordering his property returned to him.  He said he plans to spruce the place up again and reopen the hostel and party space he was running there.

Or maybe he'll sell; he says he has been offered $300,000 — 30 times what he paid — but won't settle for less than $750,000.

"That might sound like a lot, but it might actually end up being a bargain," said Wielend, his green eyes twinkling as he gazed at the ocean from the cracked and graffiti-scrawled terrace. "Who knows, maybe in 10 years this will end up being the most valuable property in all of Rio de Janeiro."