President Dilma Rousseff looks positioned to narrowly win a second term on Sunday thanks to a slight rebound in the economy and her success in portraying her rival as an elitist who would take Brazil back to a more heartless era.
Rousseff, a leftist, has a lead of about 4 percentage points in polls against Senator Aecio Neves of the centrist Brazilian Social Democracy Party (PSDB), who proposes more market-friendly policies focused on trade and fiscal austerity.
The president's lead is within the margin of error in most polls, which badly understated Neves' support in the first round of voting on Oct. 5. Both camps, therefore, have warned against reading polls too closely and some analysts say the race is still a toss up.
But the overall momentum has been in Rousseff's favor, thanks to swelling support from Brazil's lower-middle class - generally defined as people in households earning between about $700 and $1,800 a month.
That group, which accounts for about 40 percent of the electorate, has benefited greatly under Rousseff's Workers' Party over the past 12 years. Many of them seem to have concluded that things in Brazil just aren't that bad - so the risk of switching to Neves isn't worth it.
A senior adviser to Neves' campaign acknowledged that he has had a bad week, although he noted that he staged a late comeback in the first round and could do so again.
"It's been a campaign of fear," the adviser said. "It's disgusting. But we believe people will see the truth by Sunday."
Brazil's economy has slowed dramatically since Rousseff took office in 2011, and suffered a light recession early this year, fueling opposition to her interventionist policies on Wall Street and in big manufacturing centers such as Sao Paulo.
Nevertheless, the economy grew again in July and August, according to a central bank indicator, which would be the first two consecutive months of expansion since mid-2013.
Brazilian workers received an average wage increase of 3 percentage points above inflation this year, double what they received in 2013. Unemployment is near all-time lows, falling to 4.9 percent last month.
There has also been a recent improvement in perceptions of the economy with just 15 percent of voters telling the Datafolha polling firm that they expect the economy to worsen, down from 25 percent in late September and 36 percent in early June.
Rousseff and her campaign team have warned that Neves, the scion of a wealthy political family who owns a beachside apartment in Rio de Janeiro, would take Brazil "back to the past" - a reference to the PSDB government of the 1990s, before a boom in commodities prices and the rollout of social welfare programs led to a sharp fall in poverty.
The warnings have taken their toll in places like Mateus Leme, a town of about 28,000 people in Minas Gerais state, where Neves was a popular governor but is now seen warily.
"People are afraid of him," said Jose Vicente de Paulo, 76. "Life got a little bit better, and everybody says he'll take that away."
Mateus Leme has benefited from the opening of nearby auto parts factories, thanks to a nationwide doubling in sales of new vehicles over the past decade. While the industry has struggled over the past year, "everybody still has money in their pocket," said Ricardo Moraes, 29, a glassmaker.
Moraes said he had considered voting for Neves but recently decided "we shouldn't abandon this path."
As recently as Oct. 15, Neves enjoyed an 11 percentage point advantage among the lower-middle class, according to Datafolha. Now, the two are tied among that demographic - which, given Rousseff's hefty advantage among even poorer voters, has allowed her to take a slight lead overall.
PUMPING MONEY INTO THE ECONOMY
Rousseff's decision to effectively abandon her government's main fiscal target for this year has helped pump money into the economy. August, for example, saw the biggest budget deficit for that month in more than a decade, at about $5.9 billion.
Such tactics can't last, economists warn. Ratings agencies have said Brazil may face a downgrade unless Rousseff or Neves make sharp spending cuts in 2015, which may tip the economy into recession once again. But the election will be over by then.
Neves, meanwhile, appears to have come out on the short end of an unusually divisive campaign by Brazilian standards, which has seen countless false rumors and senior leaders from both parties publicly compare their rivals to Nazis.
A meeting of Minas Gerais state officials last week was interrupted when one official received a text message warning of one such rumor - that a federal housing program for low-income Brazilians would be suspended if Neves won.
"This again?," said Juliano Fisicaro Borges, a senior official at the state's social development secretariat, which is run by the PSDB. "It's war out there."
Meanwhile, Rousseff has appeared virtually impervious to a flurry of corruption scandals involving her party. Even a steady drum beat in Brazilian media of leaked testimony accusing senior directors at state-run oil company Petrobras of running a massive kickback scheme has not gained much traction among voters.
TENSE DEBATE A TURNING POINT
Brazil's stock market has fallen 8 percent this week, erasing all of its previous gains for 2014, and the currency has also suffered as investors sell off assets in anticipation of a Rousseff victory.
An acrimonious debate between the two candidates last week may have been a turning point. When Rousseff referenced a 2011 incident in which Neves refused to take a breathalyzer test at a road checkpoint, he expressed regret but also called Rousseff a "liar."
The exchange played badly among female voters. They supported Neves by a 46 percent to 42 percent margin in polls taken just after the first round of voting on Oct. 5, but now prefer Rousseff by a 47 percent to 41 percent margin.
"When I see a man be that ignorant with a woman ... I wonder what he'd do with a poor person," Luiz Inacio Lula da Silva, who was a popular president from 2003 to 2010 and handpicked Rousseff to succeed him, told a rally in the Amazon city of Manaus hours after the debate.
A historic drought in Sao Paulo, one of Neves' main bases of support, has also hurt him. Voters blame the state government, which is run by the PSDB, for allowing the city's main reservoir to fall to just 3 percent of its capacity - raising accusations that it is delaying rationing just because of the elections.