Brazil's leftist President Dilma Rousseff placed first in Sunday's election but did not get enough votes to avoid a runoff and will face pro-business rival Aecio Neves, who made a dramatic late surge to finish a strong second.
After Brazil's most volatile campaign in decades, which saw one candidate die in a plane crash and another soar into first place only to collapse at the end, the result ended up being what was expected a year ago - a showdown between two archrival parties that have governed the country for the last 20 years.
Rousseff will spend the next three weeks fending off an energized challenger who blames her interventionist policies for a long economic slump, and is proposing free trade and tighter government spending to recover the good will of investors.
Nevertheless, Rousseff remains a slight favorite to win, due to her party's strong record of reducing poverty and creating jobs throughout its 12 years in power, and a widespread perception that Neves' centrist Brazilian Social Democracy Party (PSDB) is beholden to the rich.
One Rousseff aide, speaking on condition of anonymity, said as results poured in that her re-election campaign team would try to cast the runoff as "the elite versus the people."
With 98 percent of votes counted, Rousseff led with 41.4 percent support compared to 33.8 percent for Neves.
Marina Silva, a prominent environmentalist who had recently led opinion polls but wilted in the final days under a barrage of negative TV ads and doubts about her shifting positions on issues, came in third place with just 21.3 percent of votes.
That provided Neves, a popular two-term governor and the grandson of a beloved politician from the 1980s, a window to present himself as a more steady alternative for voters who want a change of government.
A nationwide poll by Datafolha released on Saturday showed that, in a runoff, Rousseff would lead Neves by a margin of 48 percent to 42 percent.
But Neves seems to have a decent chance of winning. Nearly 60 percent of Silva voters had said in polls they would throw their support behind Neves, and the afterglow of his strong performance on Sunday might rally more voters behind him.
PSDB leaders have said they will try to secure Silva's formal support in coming days. When Silva finished third in the 2010 election, she remained neutral - and has given no firm indication of whether she would back anyone this time.
At Rousseff's campaign headquarters in Brasilia on Sunday night after results were released, the mood was glum.
"The second round is going to be much harder for us. The result is narrower than we expected," said one aide.
MARKET RALLY SEEMS LIKELY
Neves' unexpectedly strong finish seems likely to spark a rally in Brazil's stocks and currency on Monday among investors who have in recent months bid up assets every time a change in government seems more likely.
After growing at more than 4 percent a year during a commodities-fueled boom last decade, Brazil's economy has averaged less than 2 percent growth under Rousseff and many on Wall Street and in Sao Paulo have made no secret of their desire for more market-friendly policies.
"(Neves) has turned into a very difficult adversary for Rousseff. He has gained muscle and a new energy," said Andre Cesar, a political analyst.
Rousseff counts on a bedrock of support among the working class, thanks to generous social welfare programs and the record of her ruling Workers' Party in reducing one of the world's biggest gaps between rich and poor.
"What's at stake is continuity," said Ana Augusta de Medeiros, a 71-year-old voter in Rio de Janeiro. "I hope they will continue working on behalf of the poor."
Even after mass protests a year ago, driven by anger over corruption and poor public services, Rousseff was helped by consistently low unemployment and support from her wildly popular predecessor, Luiz Inacio Lula da Silva.
Yet others yearn for a change, pointing to poor health care and education services and infrastructure bottlenecks that have made Brazil one of the world's most expensive and difficult places to do business.
"Dilma already tried. The things that she promised she did not complete," said Rosilene Silva de Jesus, 29, who voted for Silva in Sao Paulo, Brazil's biggest city and financial capital.
Because of the topsy-turvy race, campaigning was noisier than usual in a country where the electoral process at times feels more like a carnival.
Candidates employed armies of pamphleteers and flag-wavers at street corners, while campaign jingles, often composed by celebrity musicians, blasted from sound cars and televisions.
This year's frenzy was disrupted in August, when Eduardo Campos, the original Socialist Party candidate for president, died in a plane crash.
After a week of mourning, the race was upended when Silva, who had been his running mate, took his place and soared in the polls - only to stumble at the end.