Brazil's presidential race will go to a second round after incumbent Dilma Rousseff fell short of an outright victory in Sunday's election.
She received 42% of the vote and will face centre-right rival Aecio Neves, who won 34%, on 26 October.
In a surprise result, prominent environmentalist Marina Silva got only 21% despite being a favourite at one stage, and is now out of the race.
Analysts now predict a tight contest as both candidates seek to pick up votes.
Reacting to the result Ms Rousseff - who has served one four-year term as president - said people had expressed their rejection of "the ghosts of the past, recession and unemployment", and vowed to continue to work for change.
"I clearly understood the message from the streets and from the ballot boxes. The majority of Brazilians want us to speed up the Brazil we are building," said Ms Rousseff, who heads the left-wing Workers' Party (PT).
Mr Neves, 54, a senator and former governor of Minas Gerais state, called on Ms Silva's supporters to back him, saying he represented "hope for change".
States where candidates did best
Analysis: Katy Watson, BBC News, Sao Paulo
It was the economy that was on most Brazilians' minds as they cast their votes. President Dilma Rousseff has blamed Brazil's economic woes on the global financial crisis. While to a certain extent that is true, it is not the whole picture. The social welfare programmes introduced by the Workers' Party have helped lift millions of Brazilians out of poverty, but critics would say that came at a price.
Which is where Aecio Neves comes in. He says Brazil needs to be more attractive to business to encourage investment. After all, if there's no economic growth, where does the money come from for the social spending? He wants a more independent central bank too - that way stubbornly high inflation can be reined in, something President Rousseff and her interventionist government disagree with.
The past 12 years have seen Brazil's fortunes change but people aren't worried about the past, they're concerned about the future. We will have to wait another three weeks to find out who Brazilians trust more in that respect.
Ms Silva, 56, said she and other Socialist leaders would meet in the coming days to discuss any endorsements for the run-off.
"Brazil has clearly signalled it is not for the status quo," she told reporters in Sao Paulo.
"There is no way to misinterpret the sentiment of voters, of the 60% who moved for change," she said.
More than 142 million people were eligible to vote on Sunday. Voting is mandatory for those aged between 18 and 70, and turnout was 80%.
Brazilians also elected members of congress and regional governors on Sunday.
Analysis: Wyre Davies, BBC News, Rio de Janeiro
At the end of a dramatic campaign, Brazilians are still really no closer to knowing who will lead the world's seventh-largest economy.
Although there are now two distinct visions for the future of Brazil - Aecio Neves's business-friendly image or the paternalistic interventionism of Dilma Rousseff - whoever persuades voters that they can provide a bit of both might well win the ultimate prize.
After a brief respite to gather breath, the second round is likely to take a nastier, more confrontational tone. Ms Rousseff will portray her opponent as a privatising businessman who will cut hitherto comprehensive social welfare programmes.
Likewise, Mr Neves will paint the incumbent as an idealistic socialist who will burden the country with more state spending and drive the economy into the ground.
The other main candidate, Marina Silva, fell away dramatically after having been favourite at one stage. A former environmental campaigner, she was damaged by the more powerful campaigns of her opponents. They will need some of her votes if either is to win on 26 October.
Early in the campaign, 66-year-old incumbent Ms Rousseff had been expected to win outright.
However, the race changed when Ms Silva became the Socialist candidate following the death in an air crash of original hopeful Eduardo Campos.
Last month Ms Silva was riding high in opinion polls and appeared likely to reach a second round. However her popularity later slipped as she faced concerted attacks on her ability from Ms Rousseff's campaign.
The election results have surprised many in Brazil, the BBC's Julia Carneiro in Rio de Janeiro says.
In the end, most people voted for traditional parties - the PT and Mr Neves' Social Democrats (PSDB). She adds that the main issue now is who can be trusted to revive the economy.
During Ms Rousseff's tenure as president, unemployment has been lower than under any of her predecessors, at about 5%. The minimum wage has risen and the number of undernourished Brazilians has been falling.
But the past 18 months have been marred by recession and corruption scandals, and protests over poor public services and the World Cup costs.