The official count of Mexico's presidential election has confirmed the victory of Enrique Peña Nieto, the candidate seeking to return the former autocratic ruling party to power after a 12-year hiatus, the country's electoral authority reported on Thursday night in a major step toward the resolution of the contested vote.

With just over 99% of the ballot boxes counted by 9pm, more than half of them double-checked due to the possibility of fraud, Peña Nieto had more than 38% of the vote. In second place was leftist Andrés Manuel López Obrador with more than 31%. That gave Peña Nieto a lead of more than 3.3m votes.

López Obrador alleges Peña Nieto's Institutional Revolutionary party, or PRI, engaged in vote-buying that illegally tilted millions of votes toward the party that controlled virtually all Mexico's institutions until it lost the presidency in 2000. López Obrador has not specified how many votes he believes were bought.

The ruling-party candidate who came third in Mexico's presidential elections said earlier in the day that campaign spending violations had marred the vote, although she stopped short of challenging the legitimacy of the outcome.

The complaint by the National Action party candidate Josefina Vázquez Mota nonetheless added weight to growing accusations that Peña Nieto benefited from vote-buying schemes.

The accusations are expected to become the basis of legal challenges to the final vote count, which must be certified in September by Mexico's Federal Electoral Tribunal. The tribunal has declined to overturn previously contested elections, including a 2006 presidential vote that was far closer than Sunday's.

"We need electoral authorities to conduct a detailed review of campaign spending that obviously exceeded legal limits, and that was also associated with vote buying," Vázquez Mota said. "In this election there were clear circumstances of inequity that had a decisive effect on the vote results."

Vázquez Mota said that while the complaints wouldn't invalidate the election results, they should motivate changes in electoral laws to prevent such practices in the future.

The accusations began surfacing in June, but sharpened early this week as thousands of people rushed to grocery stores on the outskirts of Mexico City Tuesday to redeem pre-paid gift cards worth about 100 pesos (£4.80), which many said they had been given to them by supporters of the PRI, prior to Sunday's elections.

Giving away such gifts is not illegal under Mexican electoral law, as long as the expense is reported to electoral authorities. But giving gifts seeking to influence votes is a crime, though is not generally viewed as grounds for overturning an election.

PRI spokesman Eduardo Sanchez said on Thursday the gift-card scheme had been "a theatrical representation" mounted by the left.

Sanchez claimed that supporters of López Obrador had taken hundreds of people to the stores, dressed them in PRI T-shirts, given them gift cards, emptied store shelves to create an appearance of panic-buying, and brought in TV cameras to create the false impression that the PRI had given out the cards.

"They mounted a clumsy farce, a theatrical representation in which they dressed people in PRI T-shirts," Sanchez said.

Cesar Yanez, the spokesman for López Obrador's campaign, denied the PRI accusation.

"That's absurd. I don't think even they believe that," said Yanez. "They would do better to just accept their responsibility."

López Obrador presented thousands of more cards on Thursday that he said had been given to PRI voters in exchange for support, saying that scheme and other vote-buying had occurred in a number of states, and brought the PRI millions of illegal votes. The candidate said his team would realize an exact figure in the coming days.

"We're getting a sense of the size of the vote-buying and the damage it caused," campaign co-ordinator Ricardo Monreal said.

Vázquez Mota also complained about pre-election polls that put Peña Nieto ahead by double digits, or about double his apparent victory margin. She said the erroneous polls "could only be interpreted as instruments of propaganda."