RIO DE JANEIRO (AP) — Incumbent Ricardo Nunes and leftist lawmaker Guilherme Boulos will face each other in a runoff to decide the next mayor of Sao Paulo, following a first round of voting Sunday in Brazil’s local elections.

Nunes, Boulos and self-help guru turned far-right politician Pablo Marçal were running neck-and-neck ahead of Sunday’s vote. Marçal only just missed out on earning a spot in the second round, slated for Oct. 27.

Much of the attention leading up to Sunday's vote had been on Brazil 's biggest city, where the race has been marred by episodes of violence involving Marçal.

Last month, José Luiz Datena, a former TV anchor turned candidate, slammed Marçal with a metal chair during a televised debate following references to allegations of sexual misconduct. In a later debate, an aide to Marçal punched an adversary's counterpart, resulting in a bloody face.

Marçal sparked more controversy on Friday, when he published on social media a falsified medical report indicating cocaine use by Boulos. The document was widely debunked by local media that pointed to inconsistencies including the fact that it was signed by a doctor who had died.

Boulos, a 42-year-old longtime campaigner for housing rights who is backed by President Luiz Inácio Lula da Silva, vehemently denied the veracity of the document. On Saturday, a judge sitting on Sao Paulo's electoral court ordered the suspension of Marçal's Instagram account for 48 hours and deemed that there are "indications of various offenses under the Electoral Code."

Some of former President Jair Bolsonaro 's political base has been drawn to Marçal, enthralled by his fiery rhetoric, although the far-right leader is supporting Nunes.

In Rio de Janeiro, incumbent Mayor Eduardo Paes was reelected for a fourth, non-consecutive term, after winning an absolute majority of votes in the first round.

Paes, an enthusiastic fan of carnival who had Lula's support, easily fought off his principal challenger, Alexandre Ramagem, the former chief of Brazil's intelligence agency under Bolsonaro. Ramagem is being investigated as part of a wider probe into alleged spying on political opponents. He has denied the accusations.

Bolsonaro backed Ramagem, and his slight ascent in the polls in recent weeks was widely attributed to the former president’s campaigning on his behalf. But in the end it proved insufficient.

Bolsonaro’s failure to spur Ramagem into the runoff vote is a setback for the former president, who built his career in Rio.

“It shows how Bolsonaro is no longer capable of getting candidates elected like he did in past elections,” said Manoel Galdino, a political scientist at the University of Sao Paulo.

But the bad news was mitigated by Bolsonaro’s son Carlos’ reelection to Rio’s municipal assembly, where he received more votes than any other councilor.

Brazilians were casting their vote to decide the next mayors, deputy mayors and councilors in the country’s 5,569 municipalities.

More than 155 million Brazilians are eligible to vote, 52% percent of them women. Forty-three percent of the electorate is in the southeastern region, where Rio and Sao Paulo are located.

Nearly 1,000 transgender politicians ran Sunday in every one of Brazil's 26 states, according to the nation's electoral court, which tracked them for the first time. The number of candidacies tripled since the last local elections four years ago, when trans rights group Antra mapped them.

A second round will be held in municipalities with more than 200,000 registered voters where, like in Sao Paulo, none of the candidates for mayor obtained an absolute majority.

___

Follow AP's Latin America coverage at https://apnews.com/hub/latin-america

A man votes in municipal elections in Rio de Janeiro, Sunday, Oct. 6, 2024. (AP Photo/Bruna Prado)

AP

icon to expand image

AP

A supporter hugs former Brazilian President Jair Bolsonaro, center, as he campaigns for Rio de Janeiro mayoral candidate Alexandre Ramagem during the municipal elections in Rio de Janeiro, Sunday, Oct. 6, 2024. (AP Photo/Bruna Prado)

AP

icon to expand image

AP

Brazilian President Luiz Inacio Lula da Silva, left, campaigns with mayoral candidate Guilherme Boulos of the Socialism and Liberty Party the day before elections in Sao Paulo, Saturday, Oct. 5, 2024. (AP Photo/Andre Penner)

AP

icon to expand image

AP

Leaflets for candidates in the municipal elections lie scattered in the Rocinha community of Rio de Janeiro, Sunday, Oct. 6, 2024. (AP Photo/Bruna Prado)

AP

icon to expand image

AP

A supporter takes a selfie with former President Jair Bolsonaro as he accompanies Rio de Janeiro mayoral candidate Alexandre Ramagem during the municipal elections in Rio de Janeiro, Sunday, Oct. 6, 2024. (AP Photo/Bruna Prado)

AP

icon to expand image

AP

Brazilian President Luiz Inacio Lula da Silva, left, campaigns with mayoral candidate Guilherme Boulos of the Socialism and Liberty Party the day before elections in Sao Paulo, Saturday, Oct. 5, 2024. (AP Photo/Andre Penner)

AP

icon to expand image

AP

Mayoral candidate Guilherme Boulos of the Socialism and Liberty Party campaigns the day before elections in Sao Paulo, Saturday, Oct. 5, 2024. (AP Photo/Andre Penner)

AP

icon to expand image

AP

Mayoral candidate Guilherme Boulos of the Socialism and Liberty Party, center, gestures to supporters as he campaigns with Brazilian President Luiz Inacio Lula da Silva, right, and his running mate Marta Suplicy, left, the day before elections in Sao Paulo, Saturday, Oct. 5, 2024. (AP Photo/Andre Penner)

AP

icon to expand image

AP

Former President Jair Bolsonaro campaigns for Rio de Janeiro mayoral candidate Alexandre Ramagem, not pictured, of the Liberal Party, during municipal elections in Rio de Janeiro, Sunday, Oct. 6, 2024. (AP Photo/Bruna Prado)

AP

icon to expand image

AP

Mayoral candidate Guilherme Boulos of the Socialism and Liberty Party, right, campaigns with Brazilian President Luiz Inacio Lula da Silva the day before elections in Sao Paulo, Saturday, Oct. 5, 2024. (AP Photo/Andre Penner)

AP

icon to expand image

AP