The Rio state security secretariat, which oversees all police forces, said the shooting would be investigated.
Rocinha has been the scene of severe violence for a month as rival gangs have clashed with each other for control over the drug trade. Intense shootouts between the gangs and also with police have taken place almost daily.
Several other slums in the city that hosted the 2016 Olympics have also seen increased shootouts.
For several months police have struggled to maintain control of the city. President Michel Temer in July authorized the use of about 9,000 army soldiers to help patrol Rio, but it has had little effect on tamping down the violence.
More about: #Spain