Media playback is unsupported on your device Media caption Mr Pena Nieto of the PRI denied allegations his party had bought votes

Mexico's electoral authorities have announced a recount of votes cast at more than half the polling stations in Sunday's presidential election after finding inconsistencies.

Andres Manuel Lopez Obrador of the leftist PRD had demanded a total recount after initial results put him in second place.

He accused leading candidate Enrique Pena Nieto of breaking electoral rules.

Mr Pena Nieto of the PRI denied allegations his party had bought votes.

Preliminary results gave Mr Pena Nieto a lead of more than six percentage points over Mr Lopez Obrador.

Executive Secretary of the Federal Electoral Institute (IFE) Edmundo Jacobo said the recount was "an exercise in openness and transparency".

Analysis For Mr Lopez Obrador's supporters this recount is very welcome. Almost from the moment polls closed, they have demanded an investigation into claims the vote was fraudulent. Recounting the votes at more than half the country's 143,000 polling stations is a massive undertaking, but Mr Lopez Obrador insists it is needed following allegations of vote-buying by Mr Pena Nieto's PRI. Mr Lopez Obrador's claims coupled with videos appearing on YouTube of people claiming to have received credit at supermarkets in exchange for voting for the PRI appear to have sparked the electoral authorities into action. But Mr Pena Nieto told me he was "totally, totally certain the party acted within the law". When I asked him if he would support a recount, simply to clarify the result, he made it very clear he thought recounts were only necessary in a handful of cases. This decision by the electoral body further frustrates his attempts to paint himself as the president-in-waiting and Mr Lopez Obrador as a sore loser. Even if Mr Pena Nieto is eventually declared president-elect, it won't be the clean victory he would have wanted.

He said votes cast at 78,012 of the 143,132 polling stations would be recounted.

Results at some two-thirds of polling stations will also be re-examined in the elections for the federal congress.

Fraud allegations

According to Mexico's electoral law, votes should be recounted if any of the following apply:

there are inconsistencies in the final tally reports

the result shows a difference of one percentage point or less between the first and second-placed candidate

all the votes in one ballot box are cast in favour of the same candidate.

Mr Lopez Obrador had demanded a full recount citing evidence of widespread irregularities.

"Where these things happen, there needs to be a recount of the votes. It is not asking for a favour; it is asking for the law to be fulfilled," he said on Tuesday.

He has said the process itself was neither fair nor clean, accusing Mr Pena Nieto's Institutional Revolutionary party (PRI) of spending more than their allotted electoral budget and condemning biased media coverage.

There have also been allegations of vote-buying, which Mr Pena Nieto denied.

He told the BBC's Will Grant in Mexico City that he was "completely clear that the party acted within the law".

Asked about videos showing voters claiming they received credit with a major supermarket chain in exchange for their votes, Mr Pena Nieto said they had been faked.

'Sore loser'

He added that although vote-counting was still under way, there was no doubt the Mexican people had expressed their will, giving him a lead over his nearest rival of more than 3.2m votes.

Image caption The electoral authorities have until 6 September to declare a president-elect

Mr Pena Nieto said he was disappointed Mr Lopez Obrador had not recognised the result.

He said his rival had a long record of refusing to accept defeat.

After losing the 2006 presidential election by a narrow margin to Felipe Calderon, Mr Lopez Obrador launched street protests that lasted for several months.

Preliminary results put Mr Pena Nieto on 38.15% and Mr Lopez Obrador on 31.64%.

The BBC's Will Grant in Mexico City says Mr Pena Nieto now faces an uncomfortable period.

Our correspondent says even though he continues to hold the lead, there is a long legal process to go before any candidate is officially confirmed as Mexico's president-elect.

The final official results after the count and recount should be completed by next Sunday.

But the IFE has until 6 September to address complaints and formally announce a winner.