The leftist mayoral candidate, Marcelo Freixo, is headed to the second round against evangelical senator Marcelo Crivella in Rio de Janeiro.
The results for Freixo, from the Socialism and Freedom Party, are already a victory for left forces in a city that has been led by conservative parties for many years.
The current Rio de Janeiro mayor Eduardo Paes has been under fire for months for redirecting teachers' salaries and education funds toward the Summer Olympics.
Activists have also denounced the Rio government for its policies that repressed and uprooted poor communities to make way for the World Cup and Summer Olympics, caring more about the mega-games than the city's poorer residents.
Freixo has worked against police violence in Rio and is the current chair of the Defense of Human Rights Commission of the Legislative Assembly.
The news was a bright spot for the left amid otherwise disappointing municipal elections.
The Workers' Party of impeached President Dilma Rousseff lost four of five state capitals in the races, including Sao Paulo, where millionaire Joao Doria of the right-wing Brazilian Social Democratic Party won outright.
The Workers' Party also lost two-thirds of the municipalities it had won in 2012. More than 5,500 municipal mayors' offices were up for grabs in the regional elections.
For nearly two years, mainstream media and conservative movements have led a nation-wide campaign against the PT, which came to office in 2003 when Luiz Inacio Lula da Silva won the presidency until Dilma Rousseff was recently impeached in August.
The PT setbacks were surely tied to its being endlessly linked in this campaign to corruption and the Petrobras scandal.
But Workers' Party supporters say this has only been a smokescreen to remove the PT from power and hide the real corruption of the conservative parties such as PMDB and PSDB which are now running the government, and which were largely responsible for Rousseff's impeachment.
According to a recent report by the Brazilian magazine Congresso em Foco, these two parties had the highest number of candidates barred from running for office in Sunday's elections due to corruption or other charges. Three hundred and six members of coup president Michel Temer's PMDB party were considered ineligible, and 209 members from the conservative PSDB were barred.
The PT was twelfth on the list of ineligible candidates.
Second round elections will take place on Oct. 30.