A federal court dealt a major blow to the Guantanamo Bay military commissions Tuesday, throwing out more than three years of proceedings in the case against the alleged mastermind of the 2000 bombing of the USS Cole.

In a unanimous decision, a three-judge panel from the U.S. Court of Appeals for the District of Columbia Circuit ruled that former military judge Vance Spath “created a disqualifying appearance of partiality” by pursuing a position as an immigration judge while also overseeing the case.

The judges also voided an order issued by Spath that sought to require two defense attorneys for the defendant, Abd al-Rahim al-Nashiri, to return to the case against their will.

The ruling is the latest blemish for the troubled commissions set up in the wake of the Sept. 11, 2001, attacks to try prisoners held at Guantanamo Bay, Cuba. Of a once-vast detainee population there, only 40 inmates remain. Nearly two decades after the attacks, the start of the trial of 9/11 suspects remains far off amid seemingly endless legal wrangling and procedural delays.

Nashiri, a Saudi national in his 50s, faces a possible death penalty for his alleged orchestration of a string of plots to bomb Western vessels, including the Cole attack, which killed 17 Americans. After his capture, Nashiri was subject to extensive torture in CIA custody.

“Many years ago, when Abd al-Rahim first heard he was being handed over to the Americans, he was actually happy because he thought the United States was a country of laws and rights and that he’d at least be treated fairly,” said Navy Lt. Alaric Piette, a member of Nashiri’s defense team. “Finally, after 16 years, with this ruling, that has actually happened. Which is to say that this will mean a lot to him.”

A year into his involvement in the case, Spath meanwhile quietly applied to the Justice Department for a position as an immigration judge. Such judges are appointed by the attorney general.

The D.C. Circuit judges, in a stinging rebuke, responded this week by throwing out rulings in the case from the commission and at least some from its appeals body, beginning at the moment when Spath initiated his job application in November 2015.

“This much is clear: whenever and however military judges are assigned, rehired, and reviewed, they must always maintain the appearance of impartiality,” Tatel wrote.

The CMCR is the Guantanamo appeals body. Tatel was joined on the panel by Judges Judith Rogers and Thomas Griffith.

Michael Paradis, an attorney who represented Nashiri in the D.C. Circuit case, said the opinion revealed the judges’ frustration “that the system is cavalier about such basic roles and so broken as a consequence. The whole thing has become so shambolic.”

The government could appeal the ruling. A spokeswoman for the Justice Department declined to comment on pending litigation.

Spath’s successor on the military court also left to become an immigration judge.

Devlin Barrett, Maria Sacchetti and Nick Miroff contributed to this report.