Once the Federal Electoral Institute (IFE) announces the official result, candidates have four days to lodge a legal complaint with the electoral court.

The Federal Electoral Tribunal, the ultimate arbiter of disputes, has until early September to certify the winner.

The extremely close result only confirms the divisions that exist between the right and left of Mexican politics, says the BBC's Daniel Lak in Mexico City.

The poor and working class voters who support Mr Lopez Obrador with almost fanatical devotion are being told that the election and the country have been stolen from them, our correspondent says.

Mr Calderon's backers in the middle and upper classes and the business community will be relieved that their candidate has apparently won, but apprehensive about the confrontation and possible unrest to come, he adds.

The successor to President Vicente Fox is due to be inaugurated on 1 December.