In a rare foray into the realm of foreign policy, the U.S. Supreme Court ruled Wednesday that the Iranian government must use $2 billion in frozen assets to compensate U.S. victims of terrorist attacks, rejecting Tehran’s argument that Congress had exceeded its constitutional limits by intervening in the case.

On one side of the case, Bank Markazi v. Peterson, were more than 1,000 American victims of terrorist attacks linked to Iran, as well as their surviving family members. Opposing them was the Iranian government’s central bank. The case’s namesake, Deborah Peterson, lost her brother in the 1983 truck bombing of the U.S. Marine barracks in Beirut, Lebanon. She and hundreds of others launched a wrongful-death suit against Iran in 2001. A federal district court awarded them a $2.65 billion judgment in 2007.

While the parties argued in court about how and whether Iran would pay the judgment, Congress passed the Iran Threat Reduction and Syria Human Rights Act of 2012, which included a section that made $2 billion in frozen Iranian funds available for seizure in the Bank Markazi case, citing it by name.

The Second Circuit Court of Appeals, using the new law, then sided with the families in 2014 to seize the funds. In response, Iran asked the justices to intervene against Congress’ alleged encroachment on the judicial branch’s powers to decide cases. Previous Supreme Court rulings forbade Congress from forcing courts to hand down specific verdicts or reopen final judgments.

But the Supreme Court ruled Wednesday no such encroachment had taken place. “Congress, our decisions make clear, may amend the law and make the change applicable to pending cases, even when the amendment is outcome determinative,” Justice Ruth Bader Ginsburg wrote for a 6-2 majority. “In accord with the courts below, we perceive in §8772 no violation of separation-of-powers principles, and no threat to the independence of the Judiciary.”

Chief Justice John Roberts, joined by Justice Sonia Sotomayor in a rare alliance, strongly disagreed with Ginsburg’s portrayal of the implications. “Hereafter, with this Court’s seal of approval, Congress can unabashedly pick the winners and losers in particular pending cases,” he warned.

In a possible nod to a lay audience, Roberts outlined the ruling’s significance without legalistic terms with a hypothetical case he called Smith v. Jones.

Imagine your neighbor sues you, claiming that your fence is on his property. His evidence is a letter from the previous owner of your home, accepting your neighbor’s version of the facts. Your defense is an official county map, which under state law establishes the boundaries of your land. The map shows the fence on your side of the property line. You also argue that your neighbor’s claim is six months outside the statute of limitations.

Now imagine that while the lawsuit is pending, your neighbor persuades the legislature to enact a new statute. The new statute provides that for your case, and your case alone, a letter from one neighbor to another is conclusive of property boundaries, and the statute of limitations is one year longer. Your neighbor wins. Who would you say decided your case: the legislature, which targeted your specific case and eliminated your specific defenses so as to ensure your neighbor’s victory, or the court, which presided over the fait accompli?

Ginsburg dismissed his hypothetical as absurd. “Of course, the hypothesized law would be invalid—as would a law directing judgment for Smith, for instance, if the court finds that the sun rises in the east,” she wrote. “By contrast, §8772 provides a new standard clarifying that, if Iran owns certain assets, the victims of Iran-sponsored terrorist attacks will be permitted to execute against those assets.”

The Court’s ruling came as President Obama met with Saudi Arabia’s King Salman in Riyadh. His trip is aimed at reducing friction between the White House and Middle East nations about the White House’s attempts at rapprochement with Iran and the president’s perspective on regional security.