Justices of the Supreme Court enter the Capitol before President Obama’s State of the Union address on Tuesday night. (Melina Mara/The Washington Post)

The issue at the Supreme Court was terrorism backed by Iran and whether American victims and their families who sued that country should have an easier path to recovering billions of dollars in damages.

But at oral arguments Wednesday, it was Congress that was on trial, for allegedly overstepping its powers by passing a law that essentially guaranteed a legal victory for the victims.

And, according to the chief justice of the United States, that kind of legislative behavior could put the independence of the country’s judiciary at risk.

It is Congress’s job to pass laws, Chief Justice John G. Roberts Jr. said during a tough round of questioning for the lawyers representing the victims and the government, but it is a judge’s job to decide cases without interference.

“There are places in the world where courts function just the way our courts do, except every now and then, when there’s a case that the strongman who runs the country is interested in . . . he picks up the phone and he tells the court: You decide this case this way,” Roberts told Washington lawyer Theodore Olson, who was arguing on behalf of the victims. “I’m not sure I see what the difference is here.”

It seemed likely that the victims might yet prevail. Several justices indicated they believed Congress had the power to pass the 2012 law at issue. The court is often most deferential when the executive and legislative branches are united, as they are here, on a matter that affects this country’s relationship with another.

“Doesn’t it make a difference that this is in the area of foreign affairs?” Justice Elena Kagan asked Washington lawyer Jeffrey A. Lamken, who was representing the central bank of Iran, Bank Markazi. “I had thought that our cases were pretty clear that the political branches . . . have a great deal of power in this area, even when it comes to very particular controversies.”

The beneficiaries of the law Lamken’s client was contesting are 1,300 Americans who were wounded by or are survivors of those killed in terrorist attacks, kidnappings and bombings guided by the Iranian government, including many who were killed in the 1983 Beirut Marine barracks bombing.

The suit involved survivors of 173 of the 241 killed in that attack who had secured judgments against Iran and who courts had said were entitled to more than $10 billion in compensation.

When those who had secured judgments against Iran learned of bonds in a New York bank that had been frozen by the U.S. government, they went after them.

After lobbying by the families, Congress passed a law in the midst of the litigation that essentially said the victims were entitled to the funds. The legislation even named the suit. The lead plaintiff in the suit was Deborah Peterson of Arlington, Va., who was seeking to avenge the killing of her brother, 20-year-old Marine Cpl. James Knipple.

Lower courts sided with the plaintiffs and said Congress had not violated the separation of powers by its actions.

But Lamken told the Supreme Court that was wrong.

“For nearly 200 years, Congress never enacted a statute that purported to limit the effect to one and only one specified case,” Lamken said in his opening remarks to the court.

He concluded by saying that if the court blesses the statute, “the lesson it teaches the populace is: If you want to win your case in court, don’t hire a lawyer; hire a lobbyist.”

But aside from what appeared to be a powerful friend in the chief justice, Lamken often encountered a bumpy road.

Justice Ruth Bader Ginsburg suggested that congressional action was broader, affecting not just one case but a combination of 19, representing a large swath of plaintiffs.

Justice Samuel A. Alito Jr. said a “creative drafter” could draw up a bill that accomplished the same outcome for the plaintiffs without mentioning the specific case.

Justice Antonin Scalia asked: “Where do you get the notion that Congress can only act by generality? It acts all the time on individual matters.”

Justice Stephen G. Breyer noted that Congress often passes private bills delivering judgments for individuals.

Lamken calmly swatted each example away. Congress may do many things, he said, but it cannot ordain a winner in an ongoing lawsuit.

In this case, Congress did not “merely say, ‘new law for this particular case,’ but says “new law, plaintiffs win,’ ” Lamken said. “That is certainly, certainly, across the line. And that is effectively what Congress did here.”

Olson agreed that the legal system would not “tolerate Congress directing an outcome of a specific case: ‘A’ must win and ‘B’ must lose.” But he said it was perfectly fine for Congress to make a substantial change in the law while litigation was ongoing.

The important legal decision, he said, was when courts “determined by clear and convincing evidence that the government of Iran sponsored terrorism that killed and maimed American citizens.”

Congress was making it easier to collect on the resulting judgments, Olson said.

That failed to assuage Roberts. He hypothesized about a congressional committee that looked at the docket at the beginning of each Supreme Court term.

“They read the briefs. And they say, well, we think this one should come out this way. And they pass a law telling us, in case number 15185, the Supreme Court will enter judgment” for Congress’s preferred winner, Roberts said.

Deputy Solicitor General Edwin S. Kneedler said the court has recognized for hundreds of years that “Congress may amend the law and make it applicable to pending cases, and the court must give effect to that law. That is what Congress did here.”

Not all of the justices were as concerned as Roberts about the effect on judicial independence, particularly Alito.

“You think the issue here is the protection of the judiciary rather than providing a certain element of equal treatment for the people who are the litigants in the case?” he asked Lamken. “I would think it would be the opposite.”

Ginsburg pointed out that if the specific law at issue is struck down, there are other avenues for the families to recover the money. And those families who are not part of the current case are also pursuing judgments against Iran on behalf of their relatives. Congress has shown interest in trying to more completely compensate those who have suffered because of terrorist acts.

The case is Bank Markazi v. Peterson.