MEXICO CITY (Reuters) - With a tight general election looming next year, Mexican President Enrique Pena Nieto faces a tough choice on whether to pursue a graft probe involving a prominent ally and Brazilian construction firm Odebrecht.

Mexico's President Enrique Pena Nieto is pictured after delivering his speech during a ceremony ahead of the Rio 2016 Olympic Games at Los Pinos presidential residence in Mexico City, Mexico, July 21, 2016. REUTERS/Edgard Garrido Picture Supplied by Action Images

Mexico’s top prosecutor, acting Attorney General, Alberto Elias Beltran, on Friday fired the federal attorney general responsible for electoral crimes, adding fuel to a case that may complicate the president’s efforts to shake off allegations of corruption in the run-up to the July 2018 presidential vote.

The dismissal of top electoral prosecutor, Santiago Nieto, came two days after he accused Emilio Lozoya, the former boss of state oil firm Pemex, and a longtime ally of President Pena Nieto, in a newspaper interview of writing to him to ask to be declared innocent of funneling Odebrecht cash to political campaigns.

In Brazil, Odebrecht has admitted to paying bribes in several countries in Latin America, including Mexico.

President Pena Nieto’s party, the Institutional Revolutionary Party (PRI), has been the dominant force of Mexican politics for the best part of a century, but has long been a byword for corruption.

Mindful that the issue of corruption has become central to the 2018 election, the unpopular PRI has overseen the arrest of various former state governors, but Lozoya poses a more difficult challenge, given his proximity to the president.

“If they investigate (Lozoya) deeply, I think it would be the end of the party in power. If they don’t, they stir up more public anger,” said Paulo Diez, an anti-corruption lawyer who has taken on the government in high-profile graft scandals.

Four days after becoming acting Attorney General, Alberto Elias Beltran dismissed Santiago Nieto on the grounds he had broken the office’s code of conduct for public officials, his office said on Friday.

The dismissal was attacked by the conservative National Action Party (PAN) and the leftist Party of the Democratic Revolution (PRD), opposition parties which questioned the impartiality of Pena Nieto’s government.

Santiago Nieto told newspaper Reforma on Wednesday that Lozoya’s letter was a bid to secure “impunity” and that Odebrecht money had entered political campaigns. Nieto’s office confirmed the letter’s existence, as well as the investigation into the former Pemex chief executive, when contacted by Reuters.

Lozoya said in a press conference that he is innocent of all accusations and that he did not funnel cash to President Pena Nieto’s campaign.

President Pena Nieto has also previously denied Odebrecht bribes made their way into his party’s coffers.

Lozoya’s lawyer, Javier Coello, denied his client had written seeking leniency interviews.

Coello also shared with Reuters a letter sent to Santiago Nieto, in which Lozoya asked to be informed of any criminal investigation into him, and to be called to testify if needed. That letter did not mention any appeals for clemency.

Odebrecht has admitted to U.S. and Brazilian prosecutors that it paid $10.5 million in bribes in Mexico.

Details of the payments have not been made public, though in August, Brazilian and Mexican media reported that Lozoya had asked Odebrecht executives for bribes in 2012 in return for contracts, citing testimony from Odebrecht employees.

On Monday this week, Attorney General Raul Cervantes stood down, telling Senators his office had concluded investigations into Odebrecht. However, the details have yet to be published.