A few years ago, you wouldn't have gone near Santa Marta, one of Rio de Janeiro's central favelas. This higgledly-piggledly jigsaw of shacks roofed with scraps of wood, cloth and corrugated iron tumbling down the mountain of Dona Marta, was a no-go area, hitting the headlines for gun battles between drug lords.
Now, arguably, you shouldn't come to Rio without visiting Santa Marta. In 2008, police raided the shanty town, evicting dealers and gangs as the first stage of an ambitious "pacification" project, whereby Peacemaker Police Units set up permanent bases in these shanty towns. The authorities want to clean up Rio in time for the 2014 World Cup and 2016 Olympics.
Pacification is a polite, if rather unsettling, term for the controversial policy. Only 19 of Rio's most dangerous favelas have so far been subject to the enforced clean-up. However, one positive outcome is that these "communities", as they are now known, are safer for tourists to visit.
Rio is an undulating urban maze, with its glorious golden shore climaxing with the languid crescents of Ipanema and Copacabana. Look right from Ipanema, though, and Rio's unequal distribution of wealth is hard to miss: the Rocinha and Cantagalo favelas twinkle at night with the haphazard brightness that comes when you build house upon unplanned house up and up the slopes. There are thousands of these buildings, piling up across the mountain side, held up by hope and a collective determination to survive. They have grown from communities of fugitive – and later liberated – African slaves who sought refuge in the hills.
Poverty and rural exodus in the latter part of the 20th century combined to increase their volume. There are about a thousand favelas in Rio today, home to one in five of the citizens.
Gilson da Silva is 33 and has lived in Santa Marta all his life. Now he's been trained through a government scheme called Rio Top Tour, which encourages locals to become guides and teaches them English. His intention was to take me right up into the middle of Santa Marta.
"The fee you pay goes straight back into the community, helping schools and kids," he explained. "There are 4x4 tours now, run by big companies, but it's much better to be guided by the people who live here. We tell the truth, not a fairy tale."
After "pacification", a cable-car was installed at Santa Marta. Where once its 8,000 residents climbed laboriously up and down the mountain, now they ride to the top. We waited as a double mattress was loaded in, plus a couple of dogs and numerous children, before we swung up with a crowd of locals.
At the summit was a spectacular view down across the city via unsettlingly picturesque shacks painted pink, green and blue. Beyond, the skyscrapers of Zona Sul; the city pooling around mountains towards the ocean. And right above us, there were the outstretched arms of Christ the Redeemer, swathed in mist atop Corcorvado mountain.
"Ten years ago it was unthinkable that you'd be here," said Gilson, as we descended steep steps past open doors revealing floral sofas and flickering TVs. Brazilian pop blared from behind closed shutters; tiny bakeries and makeshift bars, cut through with open sewers, complex overhead tangles of unregulated electrical wiring and tropical vegetation springing through crumbling walls.
"Living in a favela completely excluded us from life in Rio. You couldn't get a job because when you gave your address they assumed you couldn't be trusted. Now we're part of it and we welcome tourists. But if people come they should buy water or a cake or a beer. It's about giving back when you come to find things out."
Slowly, favelas are becoming accessible. Real estate prices are soaring; ("squatters' rights" mean that favela dwellers own the houses and plots of land they live on). But where once you could buy a house in the favelas for 22,000 reals (£8,000), now there's little below R50,000 (£18,000).
Artists and musicians are moving in and there's a favela hostel in Santa Teresa, with one of the best views in Rio going for just R90 (£30) a night.
Cantagalo, Ipanema's once-dangerous favela, is now more accessible than ever – take the new elevator straight up from the metro station into its midst.
Later, I met Marcello Armstrong, a Carioca (Rio resident) who set up Rio's first favela tour 19 years ago. For years he attracted only backpackers. But now mainstream tourists join his four-hour tour through one of Rio's "unpacified" favelas, such as Rocinha, which lies smack in the middle of the wealthy Sao Conrado neighbourhood.
"People used to be shocked at tourists visiting favelas," explained Marcello. "Now there are funk and jazz parties and favela movie shows. A sunset beer on top of the favela was unheard of a decade ago."
On the tour of Rocinha I was joined by several American couples and two English ladies. "We're visiting the only place in town that the majority of local people don't know," explained our guide Marina Schulze, who has worked in the favelas for 11 years. She pointed out the "favela art" produced by residents out of scrap metal and ring pulls. "Don't expect to find misery here. You'll find poverty but not misery; it's very different."
The only main road was lined with shops; young men hung out in bars swigging Skol beer. Moto-taxis zoomed up and down, acting both as ad-hoc transport and "spotters", watching out for police. Whether it was Marina's commentary or reality, it felt edgy and slightly dangerous.
There's still an element of voyeurism about the exercise. Were we simply peering in at poverty? Yet walk through any city in any land and if you look beyond the monuments you'll find the sprawl of local life: poverty, hardship and the small wonders of human spirit and endeavour. The tour was so packed full of information about Rio's politics and social history that I couldn't help but feel that not to have come would have been a shame.
And certainly, the people I met were pleased to see us. Alex, manning a stand of paintings, was relaxed. He gestured at the scene: "People think it's all about bandits and guns up here, but it's not – now we have the chance to let tourists find that out."
Area: 410 times the size of Wales
Year of independence: 1822
National animal: Jaguar
Opening lines of national anthem: Ouviram do Ipiranga as margens plácidas/De um povo heróico o brado retumbante (The placid banks of Ipiranga heard/The resounding cry of a heroic people)
Travel essentials: Rio
* Rio de Janeiro is served non-stop from Heathrow by BA (0844 493 0787; ba.com) and TAM (020-8897 0005; tam.com.br).
* Journey Latin America (020-8747 8315; journeylatinamerica.co.uk) sells a week in Rio for £1,440 including flights from Heathrow, transfers and B&B accommodation.
* Pousada Favelinha, Santa Teresa (favelinha. com). Doubles from R90 (£33), incl breakfast.
* Rio Top Tour can be found at the foot of Santa Marta. Prices start at 50 reals (£18) for a two-hour visit. Find more at riotoptour.com or email firstname.lastname@example.org.
* The original Favela Tour of Rocinha can be booked at favelatour.com.br or call 00 55 21 3322 2727 (R65/£23, including pick-up/drop off at your hotel).
Marcello can also provide details of monthly jazz and funk parties in the favelas.
* Brazil Tourist Board: braziltour.com
* Latin American Travel Association: 020-8715 2913; lata.orgReuse content