Police were heavily armed for their assault on the slum

Guns and grenades were used in the fighting, with armoured vehicles and helicopters backing police units.

The violence began when more than 1,000 policemen advanced on Alemao, the slum stronghold of a drug-dealing gang.

Rio de Janeiro officials are trying to make the city safer before it hosts the Pan-American games on 13 July.

Some 5,500 athletes and around 800,000 tourists are expected to visit the city for the games.

The city is also one of the host venues for the global series of Live Earth rock concerts on 7 July.

This is a war. My granddaughter was hit by a bullet in her home

Alemao resident

In pictures: Rio violence

More than 30 people had been killed and 80 injured since the police first surrounded the slums in northern Rio known as the German Complex on 2 May.

But Wednesday's police operation was the biggest to date, triggering fierce fighting for several hours in the slums which are home to some 100,000 people.

Caught in cross-fire

There were conflicting reports of how many people had died, but police said 19 had been killed in the fighting by early on Thursday.

Several people were also reported to have been injured by stray bullets.

Local residents have often been caught in the gunfire

"This is a war. My granddaughter was hit by a bullet in her home," a resident told Brazil's Agencia Estado news agency.

The authorities have defended the operation and say all those killed were suspected drug dealers.

"We must retake control of the slums and instil public order. The goal is to put an end to the traffickers' arsenals," state public safety secretary Jose Mariano Beltrame said.

Up to 1,300 officers were involved in Wednesday's raid, the majority heavily armed and wearing flak jackets and some driving in reinforced vehicles.

Gang members set up barricades and created oil slicks to slow down the police assault.

The BBC's Gary Duffy in Sao Paulo says the police face a formidable opposition as many members of the drug gangs have high-calibre weapons.

In a recent exchange of gunfire a man was killed at a petrol station up to 2km (1.2 miles) from where the shot was originally fired.

The operation has been criticised by local community groups and human rights organisations and it is clear local people have been suffering considerably, our correspondent says.

Police were patrolling the streets and controlling all access points to the slums on Thursday, officials said.

Several schools were closed.