The operation in Rocinha — which is located above some of Rio’s most exclusive residential neighborhoods — was considered the most important step yet in the effort to impose order.

Officials said the operation’s success was made possible by months of intelligence gathering and by the arrest last week of Antônio Bonfim Lopes, the drug lord known as Nem, who was said to have effectively ruled Rocinha.

“Some say it’s good; others say it’s not,” said Nilson Ferreira, 31, a doorman who lives in Vidigal, a slum near Rocinha that was also occupied on Sunday by soldiers and the police. “For me, it’s fine,” said Mr. Ferreira, who watched the police clean an area where drug traffickers had thrown oil to prevent vehicles from passing.

The occupation of Rocinha and Vidigal, which command spectacular views of Rio, is also a crucial phase in the crackdown against drug traffickers that control many of the city’s slums.