MEXICO CITY (AP) — Mexico's Congress approved a law Friday that would give the military a legal framework to act as police, despite unanimous objections from human rights groups.

President Enrique Pena Nieto is expected to sign the bill into law. The Senate made changes to the bill to try to calm fears that army troops could be used to crack down on protests or that local authorities would feel less pressure to improve their police forces.

The law lets the president issue a decree allowing military deployments for one year to certain states where there are "threats to national security" and police aren't able to cope with violence.

But the president could also grant unlimited extensions, allowing the military to become a permanent presence, as they have become in the particularly violent border state of Tamaulipas for more than a decade.

Rights groups in Mexico and abroad were quick to criticize the legislation, saying deployments could be endlessly renewed and local governments would have no need to train and recruit competent, honest law enforcement.

They said the bill was rammed through Congress without discussion and does not provide sufficient guarantees that soldiers would respect human rights of suspects, detainees or the general public.

"I don't want my children to grow up in a militarized country," said actor Diego Luna during a protest outside the Senate earlier this week.

After the law was approved, Luna posted a video to his Twitter account in which he said of Pena Nieto: "We demand he act responsibly and veto the law."

"You can't ignore so many voices," Luna said. "Let's have a dialogue that is profound and robust, the dialogue that this country deserves."

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

The bill approved Friday would allow soldiers to legally do what they have been doing ad hoc for at least a decade: conduct raids, man highway checkpoints, and pursue and detain suspects.

Even with the new law, the army cannot investigate crimes. It can only detain people caught in middle of illegal actions. That encourages troops to make up pretexts for searches or arrests, and doesn't help Mexico's woeful record on investigation and prosecution of crimes.

But since Mexican cartels use grenades and grenade launchers, machine guns and bullet-proof vehicles, they outgun most state and municipal police forces. Some police have been found working for drug cartels.

A group of United Nations human rights experts wrote in an open letter Thursday that the new law also broadly categorizes information about the military operations as national security issues, meaning such information would be kept as state secrets.

The group said the law does not provide adequate protection for human rights.

A rights group known as Security Without War said in a statement that the law could still be appealed to the Supreme Court on constitutional grounds. It expressed hope that opposition legislators will file such an appeal.

The law "does not contain controls and checks and balances to oversee the enormous military deployment it would encourage," according to the group. "It elevates to the status of a law, a public safety strategy that has been shown to have failed over the last decade."

Opposition members of the lower house later said they would file a Supreme Court appeal, claiming the law was unconstitutional and noting it had been rushed through Congress without enough time to debate it.

The Senate changes were aimed at easing concerns the army could be used to crack down on dissent. A previous version of the bill had only banned the military from intervening in "peaceful" protests, but the Senate version prevents them from interfering with political protests in general.

Senators also tacked on a requirement that localities receiving military help must draw up a plan to improve corrupt or inefficient police forces within six months.

The army has maintained a policing role in parts of Mexico since 2006, when local forces were deemed too small, corrupt or out-gunned to fight cartels and soldiers were dispatched by former President Felipe Calderon.