The seven judges voted unanimously to reject most of the legal complaints by Andres Manuel  Lopez Obrador, a candidate who said he was robbed of victory in the vote on July 2.

The decision hands almost certain victory to Felipe Calderon.

The judges, whose rulings are final and cannot be appealed against, must declare a president-elect by September 6.

Lopez Obrador's supporters have paralysed Mexico City with protests this month and he has vowed to make Mexico ungovernable if the court declares Calderon the winner of the country's most bitterly contested election in modern history.

Annulments

The initial result showed that Calderon, a former energy minister from the ruling National Action Party, won the election by only 0.58 of a percentage point or 244,000 votes.

The judges fell short of formally naming Calderon the winner but they said there were only marginal changes to the original results after recounts and annulments at some of the most fiercely contested polling stations.

Judge Jose Luna said: "Based on the annulments that were deemed necessary, all the parties lost a considerable amount of votes but that did not affect the results."

Josefina Mondragon, 55, a housewife who was one of a small group of protesters outside the court, said: "The damned judges are corrupt. They are stealing the election from us."
 
The Mexican peso rose 0.85 per cent to 10.88 a dollar as investors were convinced that pro-business Calderon will now take over from Mexico's president, Vicente Fox, on December 1.

Civil resistance
  
Lopez Obrador said there were serious irregularities at more than half the polling stations during the election.

He has demanded a full recount of all 41 million votes cast and has launched street protests that temporarily shut down central Mexico City.

If Calderon's victory is confirmed by the court, Lopez Obrador says he will either lead a civil resistance movement against his rival or set up some kind of parallel government.
   
But attendance at his mass rallies has dropped in the last two weeks and a campaign of blockading highways, government buildings and foreign banks appears to be losing steam.

Calderon, who campaigned on pro-business policies and would be an ally of the United States, was confident that the court would declare him winner.

A Calderon aide, Juan Camilo Mourino, said: "We are sure that the only thing that will come out of these legal challenges is that Felipe Calderon won the presidency legitimately."

Lopez Obrador has vowed to overhaul economic policies and to put the poor first.

Some of his supporters marched through the Zocalo, Mexico City's central square, with a fake coffin, marked "Democracy".