MEXICO CITY — Mexico’s ruling party rammed a bill through Congress’ lower house Thursday giving the military legal justification to act as police, stream-rolling objections by rights groups and opposition legislators who said it would effectively militarize the country.

Supporters of the bill said Mexico’s armed forces have to stay in the streets to fight gangs, given the incapacity or corruption of local police forces. But critics said there should still be a calm, detailed debate about whether the law should allow the army to perform law enforcement duties indefinitely, and with what limits.

The hurried approval process, in which members of the Chamber of Deputies debated and voted on a bill that most apparently had not had time to read, meant a thorough, reasoned debate did not happen.

“Blah, blah, blah. The truth is you always vote against everything,” said Arturo Alvarez, a congressman from the Green Party, an ally of the ruling Institutional Revolutionary Party. “The fact is we still need the army in the streets.”

It remains to be seen whether there will be more debate in the Senate, which will now take up the legislation.

The bill was voted through a lower house committee an hour or two before it was approved by the full body on a 248-115 vote.

“Today this congress is about to write … one of the most embarrassing and shameful pages in the history of Mexico,” said Jorge Alvarez, a congressman from the small Citizens Movement party. “The majority of congressmen and congresswomen here to vote today aren’t even familiar with the bill.”

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

Supporters said the measure would permit troops to act only for renewable one-year periods in states where the president issued a finding that local police forces weren’t up to the task. Opponents said that could make the deployments endlessly renewable.

Critics also questioned a provision that would classify as “secret” any information about deployments.

They also said the bill would make it too easy for a president to declare a state of emergency and send the army into the streets, and warned that it opened the possibility of using troops to crack down not only on cartel gunfights but also on protest movements and other demonstrations if they were not “peaceful.”

“We are doing a very rushed and not very professional job,” said opposition congressman Jorge Triana of the conservative National Action Party. “What this bill seeks to do is convert something that should be the exception into the norm.”

The Washington Office on Latin America think tank wrote that “formalizing the militarization of public security in Mexico would set a fundamentally negative precedent in Latin America,” where such arrangements are becoming more common.

President Enrique Pena Nieto’s administration has been facing violence that is now worse than during the darkest days of Mexico’s drug war. His Institutional Revolutionary Party, known as the PRI, used old-style tactics to limit debate and rush the bill through, including enlisting allies to resort to nationalist rhetoric to attack the international rights groups critical of the bill.

“We shouldn’t listen to foreign groups that want to violate our sovereignty, by attempting to define what kind of laws we should have,” Norma Martinez Guzman, a congresswoman for the tiny PRI-allied Social Encounter party. “Watch out, this is an effort we have seen from several organizations, and it deeply violates our national sovereignty.”

Mexican state governors and the PRI tend to like the law authorizing the army’s presence under loose and indefinite rules because it takes the pressure off them to engage in the long, costly and difficult process of training, equipping and paying reliable police officers who can be trusted not to go work for the drug cartels.

Dozens of human rights groups issued a statement on the eve of discussion of the new law calling for strengthening law enforcement institutions instead.

“If today, the federal and state governments haven’t lived up to their responsibility to build effective police forces, they’re even less likely to do so if they have a legal justification to fill that void with the request for military intervention,” it said.

Supporters said the bill includes requirements that the army, which has often been accused of illegal searches and arrests, and in some cases executing suspects, respect human rights.

“The issue of human rights is covered, and covered well” in the law, PRI congressman Cesar Dominguez said. “But we cannot guarantee liberties and the full exercise of rights if there isn’t a climate of public safety and peace.”

Mexico’s army and navy are some of the few remaining respected public institutions. Some regions of the country, such as the violent border state of Tamaulipas, depend entirely on the armed forces to keep some semblance of order after all city and town police forces were disbanded because officers were on the payroll of warring drug cartels.

At present, the military operates under a vague clause that allows troops to “aid” civilian law enforcement agencies when called upon to do so.

Few on either side blame the army and navy, whose leaders have made clear they would rather return troops to their barracks and concentrate on tasks the soldiers were trained for.

“They didn’t get themselves involved in this. They were made to get involved in this,” said congresswoman Norma Nahle of the leftist Morena party.

But Nahle noted that rights complaints involving the armed forces rose from about 190 cases a year before the army was called out in 2006 to about 1,075 complaints annually in recent years.

Rules already in place specify that soldiers accused of violating civilians’ rights must be tried in civilian, not military courts.