Khalid Sheikh Mohammed, the mastermind of the 9/11 terror attacks, will finally go on trial on Jan. 11, 2021 at the US military base in Guantanamo Bay, Cuba — nearly two decades after the al Qaeda attacks that killed 2,976 people on U.S. soil.

The judge in the case, Air Force Col. Shane Cohen, set the date — just months shy of the 20th anniversary of the Sept. 11, 2001 coordinated attacks involving jet airliners in New York City, Washington, DC and Pennsylvania — to start selection of a jury comprised of military officers at the war court compound called Camp Justice.

Mohammed and four other jihadis — Walid bin Attash, Ramzi Bin al-Shibh, Ammar al-Baluchi, and Mustafa Ahmed al-Hawsawi — face the death penalty in the case.

The native Pakistani and his co-defendants are charged with terrorism, hijacking aircraft, murder in violation of the laws of war, conspiracy, attacking civilians, attacking civilian objects, intentionally causing serious bodily injury and destruction of property in violation of the law of war.

Cohen’s order also lays out a number of other deadlines in a case that has been bogged down in pretrial litigation since the five defendants were arraigned in May 2012.

Mohammed was captured in March 2003 in a house in Rawalpindi, Pakistan, along with al-Hawsawi and several other Islamist goons.

In September 2006, the US revealed that Mohammed had been held at a secret overseas CIA prison — where the Justice Department said he’d been waterboarded 183 times — and that he was being transferred to Guantanamo.

During interrogation, he admitted decapitating Wall Street Journal reporter Daniel Pearl — an atrocity captured on video that quickly went viral — and took responsibility for shoe bomber Richard Reid’s failed attempt to blow up an airliner over the Atlantic Ocean, the Bali nightclub bombing in Indonesia, the 1993 World Trade Center attack and other attempted plots that fizzled.

“I was responsible for the 9/11 operation, from A to Z,” he said.

During his arraignment, Mohammed said that he wanted to represent himself and to plead guilty for his role in the 9/11 attacks and become a martyr.

The Justice Department under President Obama initially wanted to try KSM in federal court in New York, but changed course after criticism of the costs and security risks of trying him so close to Ground Zero.

Meanwhile, his lawyer said that with multiple appeals expected after what looks like a sure conviction in the military courtroom KSM will likely die before his case is finally resolved.

Attorney David Nevin told The Guardian that an initial appeal could take five years, with a circuit court appeal taking another three or four years, and four years after that, a final appeal to the Supreme Court up.

“There’s every possibility that my client will die in prison before this process is completed,” said Nevin.

“I don’t have the life expectancy statistics of someone in a US prison, also taking into account it would be someone who’s been tortured, but I’m sure it’s lower than normal,” he said.

And Terry McDermott, a co-author of the book, “The Hunt for KSM” said the main reason KSM had not been brought to trial was the torture he underwent while at the so-called black site.

Defense lawyers, he explained, argue that the confessions are worthless given that they came after the jihadis were tortured by CIA operatives.

“The whole thing would have been over pretty quickly if it weren’t for prior torture of the accused, that’s what they’ve been fighting about for 10 years, if the confessions they made should be admissible in court,” he told The Post.

The confessions, he added, came while they were already in Guantanamo, leading government prosecutors to argue that they should be admissible.

But the defense claimed they were tainted regardless of when they were given because of the lingering psychological effects of waterboarding and other harsh interrogation methods.

And the two sides are still arguing, with pre-trial hearings on their admissibility scheduled for the fall, he said.

The defendants have also asked for a deal in which they would plead guilty and then cooperate with the government’s ongoing investigations of 9/11 and al Qaeda.

But the Trump Administration has ruled out any plea bargains with the terrorists.

McDermott also said that if the trial had been held in federal court in Manhattan, KSM would have been found guilty years ago, noting that his nephew had been tried and convicted there of the first attack on the World Trade Center and that hundreds of other terror cases had been successfully prosecuted there.