Brazil's presidential election: Players and policies
No candidate in Brazil's presidential election won an outright first round victory, so the top two contenders will face each other in a run-off on 26 October.
Who will be facing whom?
With almost all the votes in the first round counted, incumbent Dilma Rousseff of the Workers' Party had a solid lead with about 42% of the vote.
She will be joined in the run-off by Aecio Neves of the centre-right Brazilian Social Democracy Party (PSDB), who got 34% of the vote.
Environmentalist Marina Silva, who until recently had been leading in pre-election opinion polls, is out of the running after only getting 21% of the vote.
Why has the election been so unpredictable?
Until mid-August, the election appeared to be heading for a predictable outcome: most opinion polls indicated a clear lead for Ms Rousseff with Mr Neves coming second.
But the sudden fatal accident of the third-ranked candidate, Eduardo Campos of the Socialist Party, injected a big dose of unpredictability.
Mr Campos was replaced by his running-mate, Marina Silva, and a sudden outpouring of grief and sympathy catapulted her into first place in the opinion polls.
For weeks, polls predicted a run-off between Ms Silva and Ms Rousseff, leaving Aecio Neves trailing a distant third.
But a late surge for Mr Neves means the battle for the presidency will now be fought between the two parties which have dominated Brazilian politics since the country returned to democracy three decades ago.
Why did Marina Silva fall behind?
Marina Silva enjoyed a surge in popularity after her nomination by the Brazilian Socialist Party in the wake of the death of Mr Campos.
Her campaign battle cry of "change" captured the imagination of many Brazilians fed up with persistent corruption scandals.
Her humble upbringing - she grew up in a poor family of rubber tappers in the Amazon - and her mixed-race background set her apart from the other candidates.
But some people within the Socialist Party questioned her commitment to their party's policies, pointing out Ms Silva had changed affiliation four times in five years.
An about-turn on her pledge to back gay marriage further alienated voters from the gay and lesbian community and their supporters.
Others who liked her message of change were concerned her evangelical religion would stand in the way of changing Brazil's restrictive abortion legislation.
Ms Silva - an environmentalist - had also worried many within the green movement when she appeased Brazil's powerful agribusiness sector by expressing support for GM crops and agriculture "on all levels".
Ms Silva herself has blamed "old politics" for her defeat. "It was a battle between David and Goliath," she said, referring to the powerful political machines of her opponents.
How has Dilma Rousseff's presidency measured up?
Statistics are in Ms Rousseff's favour.
During her tenure, unemployment has been lower than under any of her predecessors, at about 5%.
The minimum monthly wage (R$724; $304; £183) has increased despite the financial crisis and the number of undernourished Brazilians has fallen by more than 80% in the past decade, according to the UN.
To improve access to healthcare, 14,000 doctors have been drafted in from Cuba. Other social programmes have further improved the life of lower-income households, a fact that even rival candidates have acknowledged.
What's holding Ms Rousseff back?
Without the charisma possessed by her predecessor Luiz Inacio Lula da Silva, Ms Rousseff has failed to garner the same public support.
What does Mr Neves bring to the table?
Mr Neves, 54, is a member of Brazil's white political elite, whose grandfather Tancredo Neves successfully ran for the presidency in 1985 but died before taking office.
Currently a senator, Mr Neves served as the governor of Brazil's second most populous state, Minas Gerais, from 2003 to 2010.
He is seen as the candidate who is favoured by big business in Brazil and has in the past condemned President Rousseff's handling of the economy, accusing the Workers' Party of frightening off investors.
What is Marina Silva's role in the second round?
Marina Silva is still expected to play a key role in the coming weeks as who she endorses could prove decisive in the second round.
Following her defeat on Sunday, Ms Silva seemed to indicate she would consider backing Mr Neves, saying "there is no way to misinterpret the sentiment of voters, of the 60% who moved for change".
During the campaign, Ms Silva's position on economic issues mirrored that of Mr Neves in many ways.
Critics said her business-friendly policies were an attempt to woo voters from Mr Neves, but analysts argue their agreement on policies such as the need to reform the country's complicated tax system and reduce the costs faced by small businesses make it more likely that Ms Silva will endorse Mr Neves in the second round.