A former senator from the president’s Institutional Revolutionary Party, Mr. Cervantes was viewed by anti-corruption activists as Mr. Peña Nieto’s attempt to shield the party’s power brokers from investigations into graft.
Over a succession of presidencies, “the attorney general’s office has administered the prosecution of crimes and the administration of justice to protect the friends and cronies of the president or wield prosecution as a political tool,” said Juan E. Pardinas, the director general of the Mexican Institute for Competitiveness, a Mexico City research group.
Ms. Delgadillo and a constellation of other activists have been fighting for an independent attorney general, someone who would have no political allegiance who could lead a justice ministry staffed by a professional prosecutors and investigators using science and data to pursue cases.
“I think this is a huge opportunity to relaunch the debate on the need to have an autonomous and efficient prosecutor’s office,” Mr. Pardinas said.
Under a loophole in the law, Mr. Cervantes could have remained in office for nine years, with the ability to protect the Institutional Revolutionary Party even if the opposition wins next year’s presidential election.
Three years ago, the Mexican Congress approved the broad outlines of an independent ministry, but the overhaul stalled after human rights and anti-corruption groups argued that the legislation’s fine print did nothing to assure the agency’s autonomy.
It was Mr. Peña Nieto’s appointment of Mr. Cervantes, dubbed the “buddy prosecutor,” and the likelihood that he would remain in office after next year’s election, that galvanized groups as diverse as women’s rights organizations and the conservative employers federation.
“His resignation is a victory of civil society, and a direct result of all the pressure and opposition and power they have built up,” said Alonso González-Villalobos, a lawyer and advocate of criminal justice reform.
Mr. Cervantes’ fate may have been sealed last month in the newspaper Reforma that he had registered his Ferrari to a house in a low-income neighborhood in a neighboring state, a move that allowed him to avoid paying Mexico City taxes. His personal lawyer told Reforma that it had been an administrative error by the auto dealership.
In announcing his resignation on Monday, Mr. Cervantes said that he supported the goal of an independent chief prosecutor and that he was leaving to clear the air for Congress to move forward with legislation that would create an autonomous ministry. “Some legislators and politicians have used my name and my supposed ambitions as an excuse not to advance the approval of laws that would improve the conditions and tools to secure justice,” he said.
At an event on Monday afternoon, Mr. Peña Nieto said Mr. Cervantes had told him he did not want to be a distraction for the government.
The president named the deputy attorney general, Albert Elías Beltrán, as interim attorney general. He said he would probably not propose a new attorney general until after the election in July.
A coalition of groups have presented their own blueprint for the new justice ministry. “You need the right person to lead the institution and the right institutional design,” Mr. Pardinas said.
Miguel Carbonell, a constitutional lawyer at the National Autonomous University of Mexico, said, “Society is expecting a more neutral, balanced, prestigious figure that enjoys autonomy and credibility.”