Mr. Peña Nieto has ordered soldiers into more states as fragmenting gangs expand their criminal operations and local authorities simply throw up their hands. Senator Roberto Gil, an architect of the new law, said that the military now operated in 27 of Mexico’s 32 states, compared with six when Mr. Peña Nieto took office five years ago.

Mr. Gil, who is a member of the conservative opposition National Action Party, said the intent of the new law was to establish controls over the president’s power to place soldiers on the streets.

Over the past 12 years, there has been “no law, no procedures and no tracks” to guide military deployment, he said. The president’s power could be exercised arbitrarily, and governors have used military intervention as a crutch rather than set up their own police forces.

Under the new law, Mr. Gil said, the president must outline the reasons for sending in troops through a public executive order that is valid for a year. If the situation does not improve, the president can extend the intervention but must explain why.

“Federal intervention should be very precise and short-lived,” he said. In response to critics who argued that the law simply continues the bad incentive for governors and mayors to rely on military intervention, he added a clause that would require them to outline their plans — and spending — on strengthening law enforcement.

“Mexico has an addiction to the armed forces,” he said. “We need to reduce the doses until we reach abstinence.”

But critics say the addition is merely a patch on a law that gives new power to the military. “All they are doing is simulating that they listened to the criticism,” Mr. Madrazo said. “This law does not contemplate what needs to be done in terms of police reform.”