The official complete tally showed Dilma Rousseff, Lula's former cabinet chief, won 47 per cent of the vote to 33 per cent for her nearest rival, former Sao Paulo state governor Jose Serra.
That was short of the 50 per cent-plus-one-ballot threshold Rousseff required to avoid a 31 October knockout round against Serra - a round all pre-election surveys said Rousseff should have been able to avoid.
"I go into this second round with courage and energy because it gives me a chance to better lay out my proposals and plans," Rousseff told disappointed supporters in Brasilia.
The surveys had predicted Rousseff would win 50 to 52 per cent of the valid ballots Sunday.
They also suggested Rousseff would comfortably beat Serra in the second round to become Brazil's first woman president.
Serra's attempt to tar Rousseff with scandals touching people in her camp appeared to pay off in the days before the election, stalling her momentum and robbing her of support at the last minute.
But he did not benefit as much as the third-placed candidate in the race, Marina Silva, Lula's former environment minister, whose 19 per cent share of the ballots was far higher than an expected 14 per cent.
Sunday's elections, which mobilised the country's 136 million voters, also chose federal and state deputies, most of the senate, and the governors of all 26 states. Voting is compulsory in Brazil.
Lula, Brazil's most popular president ever, is leaving office at the end of the year after serving the maximum two straight terms permitted under Brazil's constitution.
He has thrown his full weight behind getting Rousseff elected, promising voters she would continue his policies that have brought prosperity to Latin America's biggest nation.
Lula hands over the reins to his successor on 1 January 2011.