MEXICO CITY (Reuters) - Mexico’s Senate on Friday voted an ally of President Andres Manuel Lopez Obrador to serve for nine years as the powerful new independent top prosecutor of the country, sparking immediate criticism that the role would remain politicized.

By an overwhelming majority, the Senate controlled by Lopez Obrador’s National Regeneration Movement (MORENA) and its allies chose Alejandro Gertz to take the post known as fiscal general that replaces the former position of attorney general.

Gertz, who was a security adviser to Lopez Obrador during the 2018 election campaign, had been serving as the acting attorney general since the president took office on Dec. 1.

The new role was created under the previous administration in a bid to strengthen Mexico’s patchy justice system.

However, disputes about the rules needed to flesh out the new system prevented the job from being filled until Lopez Obrador won a landslide victory in July, giving his party a platform in Congress to approve the necessary legislation.

Critics said that new framework did not guarantee the autonomy of the new prosecutor, and civil society groups spoke out against the role again on Friday.

“The name of the institution has changed, but it remains an arm of the executive,” Gustavo de Hoyos, head of Mexican employers confederation COPARMEX, told a news conference.

Gertz, 79, a onetime head of public security under former president Vicente Fox, pledged to be transparent and accountable in the job during a hearing with senators this week.

Mexican attorney generals were political appointees routinely swapped out at the accession of a new president. Under the law, Mexico’s presidents can serve only one six-year term.