Gunmen in Rio de Janeiro who engaged in a shootout with police took 30 people hostage Saturday at a luxury hotel popular with foreign tourists but within hours freed the captives and surrendered to police.

Police stand guard as tourists leave the Intercontinental Hotel in Rio de Janeiro after it was invaded by hostage-taking gunmen.Police stand guard as tourists leave the Intercontinental Hotel in Rio de Janeiro after it was invaded by hostage-taking gunmen. (Felipe Dana/Associated Press)

The upscale, beachside neighbourhood where the Intercontinental Hotel is located was transformed into a virtual war zone as 10 people — armed with high-calibre rifles, grenades and pistols — exchanged fire with police in a shootout that killed a bystander as she was getting out of a taxi.

Dozens of other gunmen fled into a nearby slum where the shootout had begun. Spent casings from high-calibre weapons littered the pavement in front of the hotel and residents of the neighbourhood said they were awakened by the shooting.

Amateur video aired on TV showed a group of black-clad police taking heavy fire and returning it as they took cover behind a garbage truck. Sanitation workers in bright orange jumpsuits huddled behind the truck, waiting for the onslaught to end.

A TV station also broadcast images of the shooting victim's body, which lay on the street partially covered by black plastic sheeting.

A witness, Ricardo Valladares, told Brazilian TV network Globo: "We are all frightened to death. No one is leaving the building because we don't know if there are more criminals nearby."

A police spokeswoman, who could not be identified because she was not authorized to discuss the matter, said that the gunmen held hostages in the hotel's kitchen "but we negotiated with them."

"All of the hostages are freed and 10 suspects are in custody," she said, adding that police searched the hotel for other gunmen but found none hiding inside.

Other television images showed an elite unit of Brazil's military police entering the hotel and leading away approximately 400 guests, many of whom were staying there for a dentists' convention.

Security in Rio de Janeiro is of great concern as the city prepares to host the final of the 2014 football World Cup and the 2016 Olympic Games.