The Brazilian government has appointed an army general to oversee security in the state of Rio de Janeiro, in response to growing gang violence.
President Michel Temer compared the violence to "a cancer" and said organised criminals had all but seized control of the state.
Rio's governor issued an appeal for help after the annual carnival celebrations were marred by violence.
The army will oversee police and other security services.
Overseeing the operation will be Gen Walter Souza Braga Netto, head of the Eastern Military Command. He was widely praised for his part in co-ordinating security for the 2016 Rio Olympic Games.
What led to the situation?
Signing the decree, Mr Termer said he was taking "extreme measures" because circumstances demanded it.
"The government will give tough and firm answers, taking all necessary measures to eradicate organised crime," he said.
There were chaotic scenes during the famous Rio carnival, with gun fights and looting. Three police officers died in violent clashes.
National TV news bulletins also broadcast footage of gangs surrounding and robbing tourists.
With the security situation apparently spiralling out of control, state governor Luiz Fernando Pezao made a plea to the national government saying military intervention was the only way to tackle the heavily armed gangs.
He apologised to those revellers affected, saying: "We were not ready. There were mistakes in the first days and we reinforced the patrols."