Rio de Janeiro mayor Eduardo Paes has been re-elected with an overwhelming majority, ensuring that he will remain at the city's helm during the 2016 Summer Olympics.
About 139 million Brazilians were called upon to elect 5,561 mayors and 48,000 municipal councilors for four-year terms among 450,000 candidates representing more than 20 political parties.
Paes, a member of the centrist PMDB, backed by the governing Workers' Party (PT), received 64.38 per cent of the votes, with 83.78 per cent of the votes counted, according to the supreme electoral tribunal.
His ultra-leftist rival Marcelo Freixo finished second with 28.51 per cent.
Paes campaigned on a promise to improve transportation, health and education sectors in the city, backed by a coalition of 20 parties.
More than 5,000 army and navy officers patrolled communities to support electoral officials and guarantee safety and the right to vote.
"I hope it remains this way, not only during the election day but every day. Every citizen who goes out to work deserves to be safe," Sila Arauj, a voter in Brazil's second-largest city told the Associated Press news agency of the security measures in Rio.
In a surprise result in Sao Paulo, high-profile former champion of consumer rights, Celso Russomanno, failed to make it into the second round of the mayoral election.
Instead, Jose Serra of the Social Democratic Party will face Fernando Haddad of the PT in the second round, scheduled for October 28.
The 2012 polls are also the first held under the "Clean Record" good-governance law, which bars people convicted of a wide range of crimes from serving in political office.
Under the measure, those convicted of charges such as fraud, drug trafficking, money-laundering, sexual assault and murder, are barred for running for public office for eight years.
Previously, those with criminal records were only ineligible if their cases could no longer be appealed to a higher court, a long process the could run on for decades.
But some kinks have emerged.
Out of the around 480,000 candidates running for mayor or city council in cities and towns throughout Brazil, 2,969 were being examined by Brazil's top electoral court in connection with the Clean Record law.
The volume of red-flagged candidacies is so high that the court has only processed 764 of them to date. It has not released a list of the candidates it has barred from taking office even if they win their races.
The Clean Record law is part of a broader crackdown on corruption by the government.