With 94 percent of the ballots counted, President Luiz Inacio Lula da Silva had 49.1 percent of the vote compared to 41.1 percent for center-right Geraldo Alckmin, Sao Paulo state's former governor, election authorities said.
Silva, who had been favored to win due to the economic stability and anti-poverty programs he brought to Brazil, needs 50 percent plus one vote to win the contest Sunday. If he fails to get that, he and Alckmin head to a runoff on Oct. 29.
An official announcement on a runoff was not likely until Monday or perhaps later after all the votes are counted from the remote corners of the country and Sao Paulo state, Alckmin's stronghold and Brazil's most populous state.
Silva's campaign manager, Marco Aurelio Garcia, said a first-round win for the president was still possible because many of the uncounted votes were from Brazil's impoverished northeast, which has benefited handsomely from government social programs.
"We believe that Lula will show solid growth as the vote from the northeast starts showing its weight," Garcia told reporters. "But I want to reaffirm that we always prepared ourselves for a two-round election."
However, of the 7 million uncounted votes by late Sunday, 6 million were from Sao Paulo state, where Alckmin was beating Silva.
Earlier Sunday, Silva said he was confident of a first-round victory after voting in the industrial town of Sao Bernardo Do Campo where he rose to prominence as a labor leader.
For months, polls have shown Silva easily winning the race. But Silva saw his once-commanding lead plummet on the eve of the vote as his Workers' Party was battered by allegations that party officials tried to buy a mysterious dossier that apparently contained incriminating information about a political rival.
Major newspapers ran front-page photos over the weekend showing piles of money allegedly meant to buy information showing corrupt dealings by an opponent. Local media reported the photos were leaked by federal police.
Silva's party claimed that Alckmin's supporters were involved, and filed a complaint Sunday with a judge demanding that Alckmin's candidacy be declared invalid because of the leak. The judge has said he would consider the case. Alckmin's campaign has denied involvement.
Six members of Lula's party, including an old friend who ran his personal security detail, face arrest warrants for their alleged roles in efforts to buy the damaging information and Silva fired his campaign manager days before the election. The president has repeatedly denied knowledge of any wrongdoing.
Alckmin, of the centrist Social Democracy Party, voted Sunday in Sao Paulo's upscale neighborhood of Morumbi. He said he was sure there would be a runoff election and that "ethics will defeat corruption."
For many voters, the corruption allegations appeared to be a deciding factor.
"I'm not going to tell you who I voted for, because the vote is secret," said Adelaide Venissato, a 53-year-old woman who owns a clothing store. "But I will tell you who I didn't vote for. I didn't vote for Lula. We expected so much and we got very little in terms of security and clean government."
But others seemed willing to overlook the corruption allegations because they feel their lives have gotten better during Silva's four years in office. He has brought a stable economy and social programs that have lifted millions out of poverty.
"I voted for Lula because he worried about workers and the poor," said Waldo Lima Mendonca, a 49-year-old construction worker. "And the best president for a worker is one who used to be a worker."
Silva's efforts to reduce poverty played well in the slums of Sao Paulo and Rio de Janeiro.
"Zero Hunger," his expanded food stamp-like program, guarantees about $30 a month to virtually all poor families provided they vaccinate their children and keep them in school. It distributes $325 million a month to 45 million of Brazil's 187 million citizens. The program has helped millions of Brazilians out of poverty, studies show.
More than 126 million Brazilians voted in the election for the president, governors for all 26 states and the federal district, all 513 federal deputies of the lower house and 27 of the 81 Senate seats.
Voting is mandatory in Brazil and those who fail to justify their absence both within Brazil and abroad may be fined.
A poor farmer's son who became a fiery union leader and was later elected as Brazil's first leftist president, Silva surprised many by governing as a moderate once taking office. His deft handling of the economy won him backing on Wall Street and in Brazil's shantytowns. His second-term priorities include reforming the tax and labor rules.
Silva's change in style didn't mean embracing the politics of Washington. He clashed head-on with President Bush over a U.S. proposal to create a continental free-trade area, having termed it a U.S. scheme to "annex" Latin America. Largely because of Brazil's opposition, the free-trade area never took off.