BRASILIA - When more than a million Brazilians took to the streets last year in anti-government protests, many believed it was a sign that the ruling Workers' Party would be ousted at the next election after 12 years in power.
Even three weeks ago, environmentalist opposition candidate Marina Silva was surging in opinion polls by tapping into the anti-establishment mood on the streets of major cities and promising to move beyond politics as usual.
But President Dilma Rousseff has clawed her way back into pole position ahead of the first round of voting on Sunday.
She is unlikely to win the 50 per cent needed for first-round victory on Sunday and could still face a tight vote in a runoff vote on Oct. 26, but Rousseff is the clear favourite.
Selling herself as the candidate best equipped to make changes and reminding poorer Brazilians of the anti-poverty gains of the last decade, the leftist Rousseff has also gained from a relentless flurry of TV and radio ads questioning Silva's ability to lead.
Silva grew up in poverty in the Amazon and was for long a senior figure inside the Workers' Party but she has embraced more market-friendly policies in this campaign and Rousseff's team is painting her as the candidate of a greedy financial elite determined to undo popular social welfare programs.
The attack ads, along with Silva's own missteps on the campaign trail, have turned the tables in what has been the most dramatic presidential race in Brazil since Rousseff's predecessor and political mentor, Luiz Inacio Lula da Silva, was elected as the country's first working-class leader in 2002.
Instead of cruising into a second round against the incumbent, Silva is struggling to fight off a late surge by the third-placed candidate Aecio Neves, a centrist senator and former state governor running on a pro-business platform.
The latest polls show Rousseff widening her lead with about 40 per cent support and Neves almost neck-and-neck with Silva in the battle to force a runoff.
"Hard to tell who will win. Our customers say the government should go, but I'll vote for them. I've got a job," said Antonio Feijão, a coffee shop attendant in Brasilia.
Under Rousseff, Brazil's high-flying economy slowed to a crawl as a global commodities bonanza fizzled and the government intervened in areas including the financial and electricity industries, contributing to a steep drop in business confidence.
Both Silva and Neves are vowing reforms that economists say are necessary to put the economy back on track, such as an overhaul of the Byzantine tax system and other steps aimed at lowering the cost of doing business here.
Rousseff, meanwhile, is aggressively touting the social gains poorer Brazilians have enjoyed under the 12 years of Workers' Party rule, a period that has also seen unemployment fall to near record lows even as the economy struggles.
Most investors were hoping for a change in government so Rousseff's recovery in the polls sparked a sell-off in financial markets, pushing the local currency close to a six-year low and driving up yields on Brazilian bonds.
Brazil's main stock index also fell 11.7 per cent in September, the biggest monthly drop since May 2012.
"This is an election that matters. Sometimes elections don't map dramatically to asset prices or rating, but this election does that very directly," said Eric Fine, portfolio manager of Van Eck Global's Unconstrained Emerging Markets Bond Fund.