Brazil's scandal-mired president, Luiz Inacio da Silva, was last night a whisker away from a historic second term in power.

With nearly 80% of ballots counted, the leftwing president had 49.39% of the vote. His closest rival, Geraldo Alckmin, had 40.88% Full results were still awaited from large sections of Brazil's north and north-east - the traditional support base of the president who is known simply as Lula. Votes from Sao Paulo state, where Mr Alckmin commands significant support, have also to be counted.

To avoid a second round runoff on October 29, Lula needs more than 50%.

The president cut a confident figure as he voted at a state school in Sao Bernardo do Campo, the industrial suburb of Sao Paulo where he began his political life. "The people are aware of what they are doing today," he said. "They have a lot of maturity and I am confident we will win this election. I only hope the people take their desires, their dreams and their strength to the polls so we can consolidate the changes that this country needs."

Opinion polls, however, had shown a country increasingly divided over its first working-class president. A succession of corruption scandals has cast doubt on Lula's ability to bring an ethical revolution to the shady world of Brazilian politics.

Six members of the president's Workers' party, including an old friend who ran his personal security detail, face arrest for their alleged roles in an effort to buy damaging information about Lula's political opponents. The president sacked his campaign manager days before the election.

Photographs of piles of money allegedly used to buy the information were leaked from the police to media outlets and displayed on front pages.

A study last Friday by the Ibope polling group showed Lula had about 49% of the vote, against 37% for Mr Alckmin.

As the race for Brasilia entered its final stretch, Lula also came under heavy criticism for refusing to attend a televised debate with other presidential candidates in Rio de Janeiro. "He [Lula] has sent a message to Brazilians, 'I am not interested in your opinion [and] I don't need to explain myself to anyone'," said Mr Alckmin, of the Social Democratic party, during the debate.

But last-ditch attempts by rivals to capitalise on corruption scandals were cut short after the worst air disaster in Brazilian history last Friday left 155 people dead. News of the mysterious collision between two planes over the Amazon rainforest dominated front pages on the eve of the country's largest ever election.

"The worst thing about Lula is that he never knows about anything," complained Jailson Goncalves, a 28-year-old shop attendant as he queued to vote outside a state school near the shantytown where he lives in southern Rio. "But I'll vote for him. He's given people more work and raised the minimum wage a little bit."