In recent months some favelas have been taken over by militias - consisting of retired and off-duty police officers.
They offer to rid communities of drug gangs in return for protection money.
The new state governor, Sergio Cabral, says he won't tolerate the involvement of serving police officers in parallel security forces.
Rio de Janeiro is well accustomed to gun crime but now there is a new pattern to the violence.
At the invitation of local businesses and residents, armed vigilante groups are driving drug gangs out of the favelas.
Made up of off-duty and retired police officers, the "militia" - as they are known - then charge protection money in return for keeping the peace.
But on Sunday there were further signs that the drug traffickers are fighting back.
The police say five heavily armed men tried to retake control of a favela in the north of the city.
They exchanged fire with local militia, and were later shot dead by uniformed police.
In all, nine people died - including an off-duty police officer.
It is not clear whether he had links to the militia.
Such shoot-outs are becoming a regular feature of life in Rio as militia and traffickers battle for control of communities which are lucrative to both.
Local media estimate that close to 100 favelas have been taken over by vigilante groups.
Last week, a police commander was arrested and a senior official suspended on suspicion of profiting from militia activity.
This weekend's violence comes just days before the start of the Rio Carnival, a giant street party which draws thousands of visitors from around the world.
BBCGüncelleme Tarihi: 20 Eylül 2018, 18:16