Because no good deed goes unpunished, a law passed last year to hold Russia accountable for international adventurism has now hamstrung the Pentagon’s efforts to counter Moscow’s influence, Defense Secretary Jim Mattis told lawmakers today.

“Russia is in a position, basically, to checkmate us,” Mattis said, because last year’s Countering America's Adversaries Through Sanctions Act, or CAATSA, makes it difficult for the U.S. to convert countries who have historically depended on Moscow’s defense exports into American allies. The law imposes sanctions, among other groups, on anyone who buys Russian military equipment. The secretary said there needs to be a “national security exception” for countries the U.S. is trying to woo away from Moscow.

“There are nations in the world who are trying to turn away from formerly Russian sourced weapons and systems,” Mattis told the Senate Armed Services Committee. “We only need to look at India, Vietnam, and some others to recognize that eventually we’re going to perilize ourselves.”

Lawmakers wrote CAATSA last year in response to Russia’s invasion of Ukraine and involvement in Syria; the act also imposes sanctions on Iran and North Korea for various malign activities. Congress passed the law with hearty bipartisan consensus, and President Trump begrudgingly signed it in August.

Now it poses what Mattis calls an “urgent” challenge. As in previous administrations, the current National Defense Strategy calls for strengthening security partnerships as a means to counter adversaries and bad actors. But Trump’s administration places particular emphasis on doing this through the sale and transfer of U.S. arms. The administration has been pushing to increase U.S. arms sales more broadly, upping its presence at the Singapore Arms Show earlier this year as part of its Buy America initiative and working to sell India fighter jets.

“Indonesia, for example, is in the same situation: Trying to shift to more of our airplanes, our systems, but they’ve got to do something to keep their legacy military going,” the secretary said.

Mattis asked senators to create a “national security waiver” for CAATSA in this year’s defense policy bill, which the committee is currently working on. He suggested that the power to grant such a waiver would reside with the State Department, and would help the U.S. avoid being “boxed in” by Russia.

But even as Mattis pushed for an exception to the law to court new allies, several senators doubled down on enforcing it on existing allies.

Last fall, NATO ally Turkey decided to buy Russian S-400 air defense system. At the time, Sens. John McCain, R-Ariz., and Bob Cardin, D-Maryland, respectively the chairman of the Armed Services Committee and then-ranking member of the Foreign Relations Committee, warned the Trump administration that this likely constituted a violation to the sanctions law. In his own testimony, Mattis said the prospective purchase is “causing a lot of concern.”

Officials from the Pentagon and across the administration have been trying to dissuade Ankara from sealing the deal, citing the possibility of sanctions and other issues. Last week, State Department Assistant Secretary Wess Mitchell told the House Foreign Affairs Committee that the purchase could lead to sanctions under CAATSA’s section 231 and even hurt Turkey’s participation in the F-35 program.

On Thursday, a bipartisan group of senators introduced legislation that would block F-35 sales to Turkey. If passed, the ban could be overcome only if the president certified that Turkey wasn’t endangering NATO interoperability, assets or members; unlawfully detaining U.S. citizens; or buying military equipment from sanctioned countries.