MEXICO CITY (Reuters) - Mexico's chief anti-corruption official, who last year exonerated President Enrique Pena Nieto of conflict-of-interest allegations, resigned on Monday, just hours before new graft-fighting legislation comes into effect.

Virgilio Andrade, head of the Public Administration Ministry (SFP), the government's main anti-corruption auditor, was appointed by Pena Nieto in 2015.

He was immediately asked to investigate the president, first lady Angelica Rivera and Finance Minster Luis Videgaray over revelations they had bought or made use of homes belonging to a major government contractor.

The opposition accused Andrade of a whitewash when the months-long probe exonerated all three of wrongdoing, just as the president was pledging to get tough on entrenched political corruption in Latin America's No. 2 economy.

Under the new anti-corruption measures, which the opposition has accused Pena Nieto's ruling Institutional Revolutionary Party (PRI) of seeking to water down, the new head of the SFP must now be ratified by the Senate before taking office.

Andrade said in a televised address he was standing down to make way for the implementation of the new anti-corruption system, set to be promulgated by the president later on Monday.

The reform aims to step up oversight of public officials and will create a special anti-graft prosecutor.

Corruption looks set to be a key theme in the 2018 presidential elections. The PRI suffered a major setback in regional elections in June, when voters castigated the party for its failure to root out graft and gang violence.

The PRI, which ruled Mexico from 1929 until 2000, and eventually became synonymous with political corruption, lost several bastions to the center-right National Action Party, which has made graft-fighting one of its key electoral issues.

The PRI party chairman resigned in the wake of the election results, and was last week replaced with Enrique Ochoa, the former head of the Federal Electricity Commission, who some see as a potential presidential candidate in 2018.

On assuming the mantle, Ochoa immediately singled out corruption as a major obstacle for the PRI.

(Reporting by Gabriel Stargardter and Ana Isabel Martinez Editing by W Simon)