MEXICO CITY — Outraged by the arrest in California of a former defense minister, the Mexican government is championing a law that is likely to throttle cooperation with U.S. anti-drug agents and the FBI, setting up a potential crisis in relations as President-elect Joe Biden prepares to assume office.

The legislation has taken the U.S. government by surprise. It was introduced shortly after American authorities tried to defuse tensions with Mexico by dropping drug-trafficking charges against Gen. Salvador Cienfuegos — a highly unusual move.

But the bill is a sign of the fury detonated in Mexico by the detention of Cienfuegos in Los Angeles in October. The legislation was proposed by the office of President Andrés Manuel López Obrador, whose party holds a majority in Congress. It sailed through the Senate on Wednesday night and is expected to clear the lower house soon.

The measure would require that Mexican federal, state and local officials get permission from a high-level security panel to talk with “foreign agents” such as those working for the FBI or Drug Enforcement Administration. The Mexican officials would be required to provide a written report about such meetings to the Foreign and Public Security ministries. A representative of the Foreign Ministry would have to sit in on the sessions.

“It will dramatically change the way Mexican law enforcement and U.S. law enforcement cooperate,” said Ana María Salazar, a Mexico City-based security analyst who worked in drug enforcement under the Clinton administration. “The extreme requirements will probably paralyze the relationship.”

The measure could affect a wide range of investigations — involving drug-trafficking, money-laundering, kidnapping and other crimes.

U.S. agents are unlikely to share sensitive information under such conditions because it could easily fall into the hands of corrupt officials if distributed widely, former officials say. “That would compromise agents, informants and investigations,” said Mike Vigil, a former chief of international operations for the DEA.

U.S. Attorney General William P. Barr said in a statement that the Justice Department was “troubled” by the legislation, which he said would complicate bilateral cooperation. “The passage of this legislation can only benefit the violent transnational criminal organizations and other criminals that we are jointly fighting,” he said.

Another department official said the measure could have a dramatic impact on bilateral relations. “The immediate effect is a freeze” on sharing information, said the official, who spoke on the condition of anonymity because he was not authorized to give interviews.

Drug cooperation is particularly important because Mexico is the main source of heroin and methamphetamines in the United States, as well as a major gateway for cocaine and fentanyl.

Roberto Velasco, the senior official handling U.S. affairs at the Foreign Ministry, said diplomats had met with officials from the State and Justice departments to explain details of the bill. “It is in our shared interest to continue working together on law enforcement,” he said in a statement. “The aim of the bill is for our cooperation to continue on the basis of mutual respect, and shared objectives.”

Cienfuegos served as defense minister from 2012 to 2018, under President Enrique Peña Nieto. He was charged in October in U.S. federal court with helping the H-2 drug cartel, based in northwestern Mexico, to ship heroin, cocaine and methamphetamines to the United States. He pleaded not guilty. Many Mexicans said they believed him; Cienfuegos was not widely perceived as corrupt and had worked on anti-drug efforts with U.S. officials.

The detention was seen in Mexico as a slap at the military — which is highly regarded and has become a central player in López Obrador’s security and infrastructure plans. Mexico responded to the arrest by threatening to curtail security cooperation with the United States. The Trump administration dropped the charges citing “foreign policy considerations” and sent Cienfuegos home. But that wasn’t the end of the story.

Mexican officials have portrayed the law as necessary to guarantee their sovereignty. “I think there’s a national awakening” after the Cienfuegos case, said Ricardo Monreal, a ruling-party lawmaker who guided the legislation through the Senate. “We want a harmonious relationship with the United States, but not one of subordination.”

He said the language in the legislation was originally harsher. “It was moderated because the president wants a good relationship” with Washington, he said.

Foreign Ministry officials noted that many parts of the legislation, such as providing only limited diplomatic immunity for foreign agents, are copied from bilateral agreements reached years ago. But the legislation adds new provisions. And it is part of the national security law, which allows criminal charges — even treason — against violators, noted Jorge Lara, a former senior Mexican justice official.

“This will result in many people preferring not to take the risk” of meeting with U.S. agents, he said. “This will generate a kind of paranoia.”

The law was introduced during a political vacuum in the United States, with the Trump administration on the brink of leaving office and a Biden team not yet confirmed. Mexican diplomats insist López Obrador wants a good relationship with the incoming U.S. leader. But Lara said the Mexican government could be using the measure to gain leverage with Biden.Senior members of the armed forces were infuriated by the arrest of Cienfuegos, whom many had served with over the years. The case was built in the United States, relying on intercepted BlackBerry messages allegedly involving the general and drug traffickers. But it sparked alarm among other senior members of the Mexican government who feared that the DEA might be tapping their phones.

López Obrador, a longtime leftist, has developed a surprisingly warm relationship with President Trump. But he also relies heavily on Mexico’s military, both for domestic security and numerous other duties, from building a new Mexico City airport to transporting medications during the coronavirus pandemic.

Matt Zapotosky in Washington contributed to this report.