MEXICO CITY (AP) — President Enrique Pena Nieto enacted a controversial bill Thursday giving the military a legal framework to operate as police on Mexican soil over widespread objections from human rights groups.

The Interior Security Law was passed by congress last week before going to Pena Nieto's desk for his signature. With its publication in the country's official gazette, it takes effect Friday.

The president said that he was aware the measure is "especially sensitive for public life in the country," and that he would therefore hold off on decreeing military deployments under the law until Mexico's high court determines its constitutionality.

"The nation's Supreme Court will be the constitutionally legitimized arbiter to make a final decision," Pena Nieto said. "But that does not mean there will cease to be intervention by the federation in matters of public security to aid those states that today need it."

The Interior Security Law essentially codifies for the armed forces law-enforcement actions that they have been doing ad-hoc for over a decade: conducting raids, running highway checkpoints and pursuing and detaining suspects.

It lets the president decree one-year military deployments to certain states where there are "threats to national security" and police are unable to cope with violence.

But the president could also grant unlimited extensions, potentially turning military forces into a permanent presence as they have become for more than a decade in the Gulf coast state of Tamaulipas, across the border from Texas.

Proponents of the law argue that the military is needed to fight powerful drug cartels that have not been brought to heel by civilian police departments, which are widely considered to be outgunned and often corrupt or even in cahoots with the gangs.

Critics say the law was rammed through congress without discussion and does not provide sufficient human rights guarantees. It also provides local governments with little incentive to recruit and train honest officers, they argue.

While generally respected in Mexico, the military has been accused of executing and torturing suspects. Even military officials have acknowledged that the army is not trained or designed to do police work.

Rights groups and notable personalities such as actors Diego Luna and Gael Garcia Bernal had campaigned against the law's passage and urged Pena Nieto to veto it.