CIA Director John Brennan warned on Wednesday that Congress’s override of a presidential veto of contested new legislation will pave the way for foreign nations hostile to the United States to detain American officials at will for alleged crimes, according to a statement.

Brennan expressed strong opposition to Congress's override of a bill permitting American victims of the 9/11 terror attacks to sue Saudi Arabia for its alleged involvement in the plot.

However, the bill—known as the Justice Against Sponsors of Terrorism Act, or JASTA—will also provide similar legal recourse to foreign nations, meaning that they could detain top U.S. officials, military leaders, and others.

Leading U.S. officials, including Brennan and Defense Secretary Ash Carter, have warned that the consequences of the bill would enable foreign nations to meddle in U.S. counterterrorism operations and force the disclosure of sensitive classified material.

JASTA "will have grave implications for the national security of the United States," Brennan said. "The most damaging consequence would be for those U.S. government officials who dutifully work overseas on behalf of our country. The principle of sovereign immunity protects U.S. officials every day, and is rooted in reciprocity".

"If we fail to uphold this standard for other countries, we place our own nation’s officials in danger," Brennan said. "No country has more to lose from undermining that principle than the United States—and few institutions would be at greater risk than CIA."

Carter made a similar argument earlier this week, telling top lawmakers that the legislation sets the stage for foreign nations to seize U.S. assets abroad and detain troops for alleged crimes.

A coalition of Iraqis has already vowed to take America to court for war crimes.