MEXICO CITY — The former head of Mexico’s state-run oil company, who faces charges of tax fraud and bribery, was arrested in southern Spain on Wednesday, officials said, delivering a boost to President Andrés Manuel López Obrador of Mexico in his fight to curb the nation’s endemic corruption.

The former official, Emilio Lozoya Austin, had been on the run since May, when the Mexican authorities accused him of receiving bribes in connection with the purchase of a fertilizer plant by Petróleos Mexicanos, or Pemex, the oil company he led from 2012 to 2016.

Mr. Lozoya has denied any wrongdoing.

The case against Mr. Lozoya, a top ally of Mexico’s former president, Enrique Peña Nieto, stems from a probe into a vast corruption scandal centered on Odebrecht, a Brazilian multinational construction conglomerate. Odebrecht has admitted to doling out about $800 million in bribes to government officials throughout the Americas and elsewhere to secure lucrative contracts.

The Spanish police said Mr. Lozoya was detained near a residential development in Malaga. Mr. Lozoya is believed to have been hiding recently in a luxury residential compound in the upscale seaside resort of Marbella, outside of Malaga, according to several Spanish media reports citing police sources.