The runoff election could prove particularly challenging for President Luiz Inacio Lula da Silva, who led the voting but lost ground as former Sao Paulo governor Geraldo Alckmin capitalised on claims of a campaign of dirty tricks.
But the incumbent leader known as Lula appeared unfazed, smiling and appearing relaxed at a press conference.
"Victory will take a little longer, but it will come," he said.
His opponent was equally upbeat.
"Brazil had given a chance to Lula and he lost ... Now it will give us a chance."
Lula garnered 48.6 percent of Sunday's vote to 41.6 percent for Dr Alckmin, which left him short of the simple majority he needed to win outright and avert an October 29 face-off.
Opinion polls last week credited Lula with a 12-point lead over the former state governor, but his support slipped at the last minute amid growing anger over campaign scandals that dogged his government and his leftist Worker's Party (PT).
Electorate divided
The vote result reflects the deep polarisation of a country where about a quarter of the 184 million-strong population earns less than two dollars a day.
Lula, a former shoeshine boy with little formal education, got the most support from the dirt-poor northeast of the country, while Dr Alckmin, backed by the business community, did particularly well in the better-off south, including Sao Paulo, Brazil's largest and wealthiest state.
Lula's support is attributed in part to an anti-poverty program that gives cash subsidies to more than 11 million struggling families.
The president's campaign was also buoyed by a healthy economy.
Once a firebrand leftist strike leader, Lula toned down his rhetoric after he took office in 2003. His government has maintained orthodox economic policies and restored public finances, while increasing the minimum wage.
But Dr Alckmin has described economic growth -- projected at three percent this year-- as pathetic, saying it fell well short of its potential.
He says that, if elected, he would tighten public spending so taxes and interest rates can be slashed in order to encourage growth.
He has also pledged to clean up corruption and questioned claims Lula had not been aware of campaign wrongdoings.
