Shootouts between drug gangs and police Tuesday left at least 16 alleged gang members dead and sent mourners fleeing from gunfire in a cemetery, officials said.

At least 10 drug gang members were killed in an hours-long shootout in the Mineira shantytown near the city's downtown district, Rio de Janeiro state police Col. Samuel Dionisio said.

In a second, apparently unrelated shooting, police killed six alleged drug gang members in a shantytown near Bangu on Rio's west side.

"The situation is under control now. We did what we had to do," Dionisio said in a televised interview. "It was a relatively happy action for the police because we managed to avoid something more serious."

The shooting at Mineira began early Tuesday morning when rival gangs from the Mangueira and Alemao shantytowns tried to seize control of lucrative drug dealing spots, police said.

Police surrounded the shantytown in an attempt to quell the fighting as the shootout spilled over into the Catumbi neighborhood and shut down a major tunnel connecting Rio's south and north sides.

The shooting lasted until about 11:00 a.m. local time and snarled traffic around the city.

Two bystanders were injured by stray bullets. One of the victims was shot in the head while sitting in a bus stuck in traffic by the fighting. The victim's condition could not be immediately confirmed.

Television news footage showed families with small children running for cover as officers fired assault rifles into the hills.

The shooting also spilled into a neighboring cemetery, where four burials had to be canceled, local media report.

Police arrested eight alleged drug gang members and recovered several weapons including a hand grenade, Dionisio said.

Rio de Janeiro is one of the most violent cities in the world with an annual homicide rate of around 50 per 100,000 residents.

Most of the killings have occurred in the city's more than 600 shantytowns, which are controlled primarily by heavily armed drug gangs.

On Monday, federal officials met with Rio de Janeiro Gov. Sergio Cabral to discuss deploying the army to fight violence in the city that will host the Pan American Games in July.