MEXICO CITY — The star witness in Mexico's biggest corruption scandal in years has alleged that former president Enrique Peña Nieto benefited from millions of dollars in corporate bribes that were funneled into his campaign and also used for payoffs to lawmakers to support his reforms, officials said Tuesday.

Emilio Lozoya, a former top official in Peña Nieto’s 2012 campaign, made the accusations in an appearance Tuesday before Mexican prosecutors, according to Attorney General Alejandro Gertz Manero. Lozoya said he handled the bribes from the Brazilian construction giant Odebrecht on the orders of Peña Nieto and one of his top aides, Luis Videgaray, the attorney general said in a video distributed on social media.

The allegations are the most serious yet against Peña Nieto, who has maintained that his campaign did not receive illegal donations.

While Mexican politics has long been permeated by corruption, only rarely have senior politicians faced criminal charges. Former president Luis Echeverria, who led the country from 1970 to 76, was indicted in 2006 on charges of genocide in connection with a massacre of students in 1968, when he was interior minister. He was ultimately exonerated.

“I think this is one of the most important events of the last few years,” said Jesús Silva-Herzog Márquez, a political scientist at Tecnológico de Monterrey. “There is no precedent of a senior former public official directly implicating an ex-president, and making a formal accusation against him.”

Lozoya, 45, who served as head of the state-owned oil giant Pemex from 2012 to 2016, was arrested in February in Spain on Mexican corruption charges. He was extradited last month and is reportedly cooperating with authorities, who have granted him house arrest.

President Andrés Manuel López Obrador has made fighting corruption a hallmark of his administration, which began in December 2018. Analysts noted that the former oil chief’s testimony was likely to help the current president as he faces the most difficult moments of his term. More than 50,000 people have died so far in the coronavirus epidemic, and the economy is expected to shrink about 10 percent this year, the severest contraction in decades.

Lozoya testified that he was ordered by the former president and Videgaray to use more than 100 million pesos (about $5 million) of bribe money to pay foreign consultants working on Peña Nieto’s 2012 campaign, according to the attorney general. The money allegedly came from Odebrecht, a Brazilian company that has acknowledged paying hundreds of millions of dollars in bribes to government officials around the world.

Lozoya said the former president and Videgaray also instructed him to use millions in bribes to pay off lawmakers to support reforms introduced by Peña Nieto. The ex-president had presented himself as a modernizer who opened up the energy sector to foreign investment and passed a bill allowing reelection. Peña Nieto has denied allegations of corruption.

Lozoya has turned over receipts, a video and the names of witnesses to back up his allegations, Gertz Manero said. The former president could be called on to testify, he said.

Videgaray served as finance minister and then foreign minister, becoming a crucial interlocutor with the Trump administration. He has been working as a visiting lecturer at the Massachusetts Institute of Technology. He has not commented on the latest allegations.

Peña Nieto’s Institutional Revolutionary Party essentially ran Mexico during seven decades of authoritarian rule, which ended in 2000. The party returned to power in 2012, under a system that was more democratic but did not completely break with a legacy of impunity for corrupt politicians.

Odebrecht agreed to pay at least $3.5 billion in fines after pleading guilty in 2016 to U.S. charges that it had bribed officials on three continents. Scores of political leaders and business executives in Latin America have been accused of involvement in its corruption schemes.

The company admitted in the settlement to paying $10.5 million in bribes to unidentified Mexican officials. But unlike in many other Latin American countries, judicial investigations into Odebrecht in Mexico stalled until recently.

Correction: An earlier version of this article stated incorrectly that no Mexican president or former leader in modern times had been charged with a criminal offense. Former president Luis Echeverria was indicted in 2006 on charges of genocide in connection with a massacre of students when he was interior minister in 1968. The article has been corrected.