The jewels in Brazil's crown range from opulent beaches to colourful slums, writes Geoff Cumming.

In a brand-new high rise behind Ipanema beach is an extraordinary elevator.

The lift is all that the 24-storey concrete and steel building contains. Open since June, the Rubem Braga Complex is a bridge between two worlds, linking the hedonism of Rio de Janeiro's legendary beach and boutique shopping with the slum (favela) that overlooks them.

It also connects slum dwellers to the fast subway which runs between the beach strip and Rio's commercial centre.

The lift is the most striking sign of the Rio government's determination to clean up the city's notorious favelas, communities of shonkily built brick boxes where more than half of its six million residents live.

The 25,000 residents of the Cantagalo favela above Ipanema enjoy breathtaking views of the coastline and white sand beach which draw millions to Rio each year. The square brick houses they live in are built one on top of the other with no evidence of a building code and debatable ownership rights. Tourists on the beachfront promenade below pay US$1000 ($1313) a night for a room, wander carefree in bikinis and boxer trunks, sip caipirinha cocktails and listen to samba and bossa nova. Residents are not all low-paid hotel cleaners and beach hawkers: accommodation is so expensive in Rio that white-collar workers on moderate incomes go home to the teeming favelas.

The favelas are best known, of course, for drug-related stabbings and killings and standover tactics by the drug lords.

Law and order long ago gave way to a mutual tolerance between police and gangs; schooling and community needs were an afterthought. But with Brazil preparing to host the Football World Cup in 2014 and the Olympic Games two years later, authorities are making an attempt to tame the lawlessness. The clampdown on gun-toting dealers and the crack they peddle is officially known, disconcertingly, as "pacifying" the favelas. Cleaned-up favelas such as Cantagalo are becoming an unlikely (and arguably intrusive) tourist diversion.

For those bored with lying on the beach or dancing the night away to samba bands, guided favela tours are billed as offering insight into how the real cariocas (Rio locals) live. The escorted tours are also a source of income for the favelas.

I visited Cantagalo on a walking tour with Urban Adventures and gained some appreciation of how this city of extreme contrasts maintains its famous rhythm.

Social worker Silvia Perrone insists the clean-up is more than a Beijing-style clean-out.

Legalised bars and shops in the favelas give residents the chance to establish small businesses.

The Government is building apartments to rehouse residents within the favela, buying their often-crumbling homes off them. Schools, playgrounds and community facilities are appearing.

Still, there is a long way to go. Perrone says five favelas have been pacified; the city has more than 70. There is suspicion that the government is targeting only favelas near the main tourist routes to create a safe facade, offering the criminals free reign elsewhere. And while the guns may have gone, the crack hasn't.

But the "holistic" approach agencies are now taking promises much - if it is sustained.

The visit left me with two impressions: my expectations of a grim struggle for survival did not seem the reality for most residents, and that Rio could not function without its favelas.

The second leg of our walking tour confirmed that Rio is indeed more complex than the postcard image of bronzed bodies and magnificent natural features.

The striking volcanic hills - which provide vantage points such as Sugar Loaf and Corcovado (from which Cristo Redemptor keeps watch on the city) - also separate the tourist beaches of Copacabana, Ipanema and Leblon off from the city's commercial and business core.

We took the subway, a clean and safe (at least by day) alternative to the city's gridlocked roads, to the old city centre, where striking office towers rub shoulders with French colonial and Spanish-styled public buildings.

The walking tour reveals a Rio many tourists never see, the older precincts evoking what it was like before it was "discovered". Some of Brazil's biggest natural resource industries are based here; not a bad working environment for many favela residents.

From the city centre, it's a short walk to the historic Lapa tram for a ride over the Lapa arches, an 18th century aqueduct, then up the hill to bohemian Santa Teresa. The ride confirms that health and safety laws are simply not Brazilian concepts: the track hugs the very edges of the hill in places and the tram is open-sided. But the ride neatly captures Rio's diversity with its glimpses of coastline, high-rises, favelas and national parks. Up top, once-stately mansions preside over magnificent views - the heyday of this area was the Belle Epoque of the early 20th century, when intellectuals, artists and aristocrats descended on Rio and ascended to Santa Teresa for a good party.

We stroll back down cobbled streets through the artists' quarter, past weathered stucco houses and frescoes. But the striking attraction is not an elevator, but a staircase. Originally built to link the city with the Convent of Santa Teresa, the steps are now known as Selaron's staircase, in honour of painter and tiler Jorge Selaron.

The Chilean immigrant has spent the past 20 years tiling the stairs and walls while authorities turn a blind eye. He makes a living by selling paintings and tiles to tourists from his home studio halfway up the steps. They are somewhat narrow in focus - all of pregnant women. He sometimes paints himself as pregnant. Thankfully, his Portuguese-styled tiles are more diverse.

Back at the beach, you can walk the boulevard past the Philippe Starck-designed hotel, take an outdoor table at a bar/restaurant and order a caipirinha (the signature Brazilian cocktail) for US$20. Or you can cross the road and get your caipirinha from a beachside kiosk for US$3, grab a table beneath the palms and watch the sun sink behind Ipanema's conical hills. Rio may be for the rich, but it is also for the poor.

Getting there: Intrepid Travel offers packages combining Buenos Aires, Montevideo and Rio de Janeiro with options such as Iguazu Falls and Uruguayan ranch stays.

Walking tours: Urban Adventures' Carioca Experience includes Copacabana, Ipanema, Cantagalo favela and a sunset drink at Arpoador Rock. US$35 ($45). The Santa Teresa Discovery tour includes subway to business district, tram to Santa Teresa, Ruins artists' quarter and Selaron's staircase. US$37.

Getting around: In Rio, taxis are cheap and a bit of a thrill ride as drivers weave through the gridlock at pace. Frequent buses link the southern bay suburbs with the city centre and Santa Teresa to the north.
At night, stand on a corner along the main drag and flag down a private mini-van for about $2.

The subway is clean, efficient and safe (at least by day).

Further information: See Brazil's tourism portal. Also see here.

Geoff Cumming visited Rio de Janeiro courtesy of Intrepid Travel