In 1955, the United States and Iran entered into a treaty that, although rarely mentioned, has remained in force. And even today, both governments still make use of it when they deem it useful.

The Treaty of Amity, Economic Relations, and Consular Rights continues to play a surprising role in the relationship between the two countries.

Article I could not be clearer: “There shall be firm and enduring peace and sincere friendship between the United States of America and Iran.”

In the wake of the Iranian Revolution and subsequent hostage-taking of American diplomats, the two sides severed almost all diplomatic and political ties — and yet, for reasons not entirely clear, they didn’t nullify this agreement. Relations have never been normalized, even despite the period of engagement during the Obama years that led to the landmark nuclear deal in 2015.

This peculiar history has a direct bearing on the fate of at least one U.S. citizen — Siamak Namazi — who is serving time in Tehran’s notorious Evin prison for supposedly collaborating with a “hostile government,” namely the United States.

That’s a charge often leveled at dual nationals (including me) by the Iranian judiciary. Yet at the same time, bizarrely, Iran’s supreme court has previously ruled — citing the treaty and other variables — that the Islamic Republic of Iran has no enemies. (Except for Israel, which Tehran doesn’t even consider to be a country.)

Now, remarkably, Iran is using the same treaty as the basis for a legal case it’s currently pursuing against the United States at the International Court of Justice in The Hague. Iran is taking the United States to court for violating the nuclear deal, from which the Trump administration withdrew this year. “The U.S. is publicly propagating a policy intended to damage as severely as possible Iran’s economy and Iranian national companies, and therefore inevitably Iranian nationals,” Mohsen Mohebi, who is representing Iran, said in his opening arguments. “This policy is plainly in violation of the 1955 Treaty of Amity.”

The absurdity and hypocrisy of invoking the treaty when it’s beneficial and ignoring its existence when it’s not — in this case in the same week — illustrates Iran’s “have your cake and eat it, too” attitude in international affairs, which is where the Namazi case comes into play.

“We expect that, given the Government of Iran’s confirmation of the validity of the Treaty of Amity, the Iranian Supreme Court will overturn the Namazis’ conviction,” Jared Genser, a lawyer representing the Namazi family in the United States, said Tuesday. He’s referring to a similar verdict in a case brought against Namazi’s father, Baqer, who is also a U.S. citizen. “Iran cannot, on the one hand, invoke the Treaty of Amity when filing complaints against the U.S. with the ICJ, and then, on the other, classify the U.S. as a ‘hostile’ government in order to sustain these convictions.”

Iran has displayed extreme inconsistency in deciding when it honors the treaty. It would be well advised to start honestly implementing the treaty in its handling of the Namazi case and others. Doing so would certainly give it a much stronger negotiating position when it comes to the nuclear deal and renewed sanctions.

And there is, in fact, a corresponding precedent.

In 2014, an Iranian convicted of similar charges was acquitted by a branch of the country’s supreme court on the grounds that “presently no government is in a state of hostility with Iran.” The decision further concluded that political differences with another country were not sufficient justification to consider it “hostile.”

That’s the crux of the appeal that the Namazis’ Iranian lawyers have filed with Iran’s judiciary, as well as the one Genser made with the U.N. Special Rapporteur on the Independence of Judges and Lawyers.

And yet the very same Iranian leaders who claim that the country’s judiciary is entirely independent have politicized the Namazi case from the start, putting him at the center of a high-profile propaganda campaign.

Iran is desperately trying to be considered a responsible and law-abiding member of the international community. The United Nations is the only international club that Iran belongs to, and it fancies itself a member in good standing. Several weeks from now Iranian leaders — especially President Hassan Rouhani and his foreign minister, Mohammad Javad Zarif — will descend on New York to attend the U.N. General Assembly.

They will undoubtedly use the opportunity to privately (in meetings with world leaders) and publicly (through the media) make their case against U.S. sanctions. It will be interesting to see whether they once again invoke the Treaty of Amity.

But the holier-than-thou proclamations they will undoubtedly make will ring hollow when juxtaposed with the reality that Iran is defying its own laws (and the decisions of its highest court) by continuing the unjust detention of Siamak Namazi.

Read more: