The United States has threatened to prosecute judges on the International Criminal Court if it opens an investigation into alleged U.S. war crimes in Afghanistan, calling the court “illegitimate” and “dangerous.”

National Security Advisor John Bolton, a long-time critic of the international tribunal, warned in a speech on Monday that the U.S. will use “any means necessary” to protect its citizens and those of its allies from what he described as “unjust prosecution.”

“We will not cooperate with the ICC. We will provide no assistance to the ICC. We will not join the ICC,” Bolton said. “We will let the ICC die on its own. After all, for all intents and purposes, the ICC is already dead to us.”

The court announced in November 2016 that a preliminary examination of the war in Afghanistan had found a “reasonable basis” to believe that American forces had committed war crimes of torture and related ill-treatment. This extends to secret detention facilities in Europe.

The United States is not a member of the international tribunal that is based in the Netherlands, but American citizens can still face prosecution if they commit war crimes in one of the court’s member states, which includes Afghanistan.

Fearing the announcement of a formal investigation, Bolton warned that the U.S. will not “sit quietly” if the court comes after citizens of the United States or Israel, which is facing a possible investigation for alleged crimes in Palestinian territories.

“We will ban its judges and prosecutors from entering the United States. We will sanction their funds in the U.S. financial system, and, we will prosecute them in the U.S. criminal system,” he said. “We will do the same for any company or state that assists an ICC investigation of Americans.”

Bolton added: “We will take note if any countries cooperate with ICC investigations of the United States and its allies, and we will remember that cooperation when setting U.S. foreign assistance, military assistance, and intelligence sharing levels.”

“No committee of foreign nations will tell us how to govern ourselves and defend our freedom,” he said.

According to the ICC report in 2016, at least 61 detainees are believed to have been tortured by American forces and 27 additional detainees are alleged to have been tortured by the Central Intelligence Agency. This includes alleged abuses at secret CIA detention facilities in Poland, Romania and Lithuania – all member states of the ICC.

“These alleged crimes were not the abuses of a few isolated individuals. Rather, they appear to have been committed as part of approved interrogation techniques in an attempt to extract ‘actionable intelligence’ from detainees,” the ICC said in its report at the time.

The court added that it believes that U.S. authorities ultimately ended the torture of detainees, which is why most of the alleged abuses happened in 2003 and 2004 when George W. Bush was commander-in-chief. However, some of the alleged ill-treatment continued until 2014, well into the presidency of Barack Obama.

The CIA is known to have used waterboarding and other torture techniques under President Bush in attempts to extract information from terrorism suspects, but subsequent reports indicated that the torture of detainees – who were not convicted of a crime – did not yield useful intelligence.

In March, the European Court of Human Rights ruled that Romania and Lithuania violated the rights of two al-Qaeda terror suspects by allowing the U.S. to torture them at secret CIA detention facilities. One of the two said interrogators subjected him to waterboarding, slammed him into a wall, slapped his face, played loud music while he was kept in a tall box, deprived him of food, and kept him naked in cold conditions.

Obama is believed to have ended all or at least most of the practices, but President Donald Trump was supportive of torture during his presidential campaign, vowing to bring back waterboarding and “a hell of a lot worse,” adding at one point that suspects “deserve it” even if it doesn’t work.

U.S. service members are not the only subjects of a potential investigation for alleged crimes in Afghanistan. The Taliban and their affiliated Haqqani Network have been blamed for war crimes and crimes against humanity while Afghan forces have been accused of torture and other ill-treatment.