Mexican President Andres Manuel Lopez Obrador on Friday defiantly dismissed criticism from a top U.N. official and domestic adversaries after Congress backed his plan to give the Army control over the civilian-led National Guard.

By a margin of 71 to 51, senators early on Friday passed a bill ceding control of the National Guard to the Army, which has fed concerns about the militarization of public security.

There were two abstentions. Mexico's lower house of Congress had approved the legislation last week.

The National Guard began operating in early 2019 at the behest of Lopez Obrador, who campaigned for office on a pledge to return the military to barracks after the years it had spent combating violent drug gangs. This week he said he had changed his mind about using the Army to keep the peace.

He argued the National Guard would end corruption under its predecessor, the Federal Police, and he has also extended the Army's remit into other areas of civilian life.

Still, Acting United Nations High Commissioner for Human Rights Nada Al-Nashif said the National Guard legislation was a step backwards for public security and had raised additional concerns about human rights and accountability.

"The security forces should be subordinated under civilian authorities," Al-Nashif said in a statement.

Praising legislators for approving his initiative, Lopez Obrador lashed out at critics, including the United Nations.

"When did the United Nations take a stand?," he told a regular news conference, questioning what the body had done to prevent war breaking out between Russia and Ukraine.

"These organizations that supposedly defend human rights, almost all these organizations are made up of people on the right from different countries of the world ... because they earn a lot of money for simulating, for pretending, for being go-betweens for authoritarian governments," he said.

Lopez Obrador's government has presided over record levels of violence, and opposition legislators and activists say the National Guard has also committed alleged abuses.

The legislation, which now passes to Lopez Obrador to be signed into law, gives the Army operational, financial and administrative control of the National Guard, which currently answers to the civilian-led security ministry.

The changes are almost certain to be challenged on the grounds they violate the constitution, and some senior legal experts say they are likely to be struck down in the Supreme Court.