A policeman patrols the Pavao-Pavaozinho slum after a shootout during a police operation in Rio de Janeiro, Brazil, October 10, 2016. REUTERS/Ricardo Moraes

Get the Pulse of the Market with StreetInsider.com's Pulse Picks. Get your Free Trial here.

RIO DE JANEIRO (Reuters) - The state security secretary of Rio de Janeiro will step down from his post at month's end, as violence and crime rebound in the Brazilian city and erase many of the gains made during the near-decade he was in the job.

Jose Mariano Beltrame, a former police officer who was lauded in recent years because of reduced violence and inroads against criminal gangs in Rio, on Monday submitted his resignation. In recent months he had decried a lack of resources and political commitment by the state government on security issues.

The state on Tuesday confirmed his departure following the completion of municipal elections on Oct. 30.

Rio Governor Luiz Fernando Pezão, who will soon return from leave after a bout with cancer, told Reuters the state reluctantly accepted Beltrame's resignation. "It was 10 years of service, lots of wear and lots of pressure," Pezão said.

Beltrame, 59, brought more stability to once-dangerous slums and paved the way for Rio, Brazil's second-biggest city and a metropolitan region of more than 12 million people, to host the 2014 World Cup and the Olympic Games earlier this year.

He also increasingly criticized parts of the state and municipal governments for a lack of follow-through with public services, from basic sanitation to health and education, needed to build upon security advances and truly fold marginalized neighborhoods into Rio's social fabric.

After an economic boom fizzled in recent years, the state is slashing its security budget and other public expenditures.

Falling tax revenue amid Brazil's worst recession since the Great Depression, combined with lower royalties from offshore oil fields, will cause a 2016 state deficit of as much as 20 billion reais ($6.23 billion), according to state figures.

Meanwhile, drug traffickers and other criminal gangs have grown emboldened to retake territory the state had occupied in effort to "pacify" districts that for decades had been fully controlled by outlaws.

On Monday, a daylong gun battle waged between state police and suspected traffickers in a hillside slum that overlooks some of Rio's wealthiest districts.

At least three of the suspects were killed and several policemen were injured in the fighting. A video filmed by an onlooker and broadcast by local media showed one of those shot by police plummeting from a mountainside.

Also on Monday, fighting around Cidade de Deus, another well-known slum, led local officials to close 21 schools, causing 8000 children to miss class.