A military judge on Friday threw out a key confession made by the self-proclaimed mastermind of the 9/11 attacks — in a major blow to the feds that could derail the already long-delayed case.

Head plotter Khalid Sheikh Mohammed’s 2007 statements made to FBI investigators were not voluntarily given, trial judge Lt. Col. Michael Schrama wrote in a bombshell ruling.

The US military did not make the decision public — citing a “security review” — but sources familiar with its contents said the judge axed Mohammed’s confessions from the case in the ruling, saying the admitted terrorist was subject to “severe coercion” from FBI agents.

Khalid Sheikh Mohammed is pictured in 2022..

“The prosecution has failed to prove by a preponderance of the evidence that Mr. Mohammad’s statements to the F.B.I. were voluntarily given,” Schrama concluded, according to the sources.

The decision comes just days after Schrama set Mohammed’s trial for June 2028 — with the 25th anniversary of the world-altering Sept. 11, 2001 attacks, which killed nearly 3,000 people, looming in two weeks.

The head military prosecutor overseeing the case, Rear Adm. Aaron C. Rugh, said that he would review the ruling and “make a decision on whether to appeal in the near future.”

An appeal could threaten to delay the long-simmering case yet again, as appeals of similar rulings have taken years to work their way through various courts.

KSM, the Sept. 11 mastermind, is shown shortly after his capture during a raid in Pakistan on March 1, 2003. AP

Victims’ families have long feared that Mohammed and his alleged fellow 9/11 plotters could die behind bars at Guantánamo Bay before being found guilty in a court of law.

“We have been asking for a trial date for 20 years. Hopefully, this time it is for real,” retired NYPD officer Jim Smith, whose wife Moira Smith died responding to the attacks, told The Post earlier this week.

The cases of Mohammed and alleged partners-in-crime — Walid bin Attash, Mustafa al-Hawsawi and Ammar al-Baluchi — have been notoriously delayed for decades amid a series of legal squabbles, including over whether confessions obtained via torture are admissible in court. 

The Twin Towers are seen after they were struck by planes flown by Al Qaida terrorists, as viewed from the 37th floor of the southernmost building of Waterside Plaza on the East River in New York City on Sept. 11, 2001. Getty Images

Prosecutors eventually agreed to not use evidence from torture interrogations of Mohammed and the other men at secret CIA prisons after the accused plotters were apprehended in 2003.

But they had planned to use Mohammed’s statements from his 2007 interview as a crucial piece of evidence at his trial, court papers show.

The judge has yet to rule on whether similar confessions from bin Attash and al-Hawsawi are admissible in court.

Victims’ families have long feared that Mohammed and his alleged fellow 9/11 plotters could die behind bars at Guantánamo Bay before being found guilty in a court of law. AP

The cases of all three men nearly came to a dramatic close in late 2024, when they agreed to plead guilty in exchange for avoiding the death penalty.

But amid public outcry from some victims’ families, Biden administration officials abruptly changed course and tried to cancel the deal, leading to years more of litigation without a trial. 

The news of Schrama’s Friday decision was first reported by The New York Times.