AFTER years of legal battles, Khalid Shaikh Mohammed, the alleged mastermind of the terrorist attacks of Sept. 11, 2001, will finally be put on trial before a military commission at Guantánamo Bay, Cuba, though a trial date hasn’t yet been set. If he is convicted, as expected, he will almost certainly face the death penalty. And, assuming one believes in the death penalty, it would be hard to think of a stronger candidate for its use.

But there are reasons Mr. Mohammed should not be executed, irrespective of how one feels about capital punishment. He was the victim of blatantly illegal treatment — the C.I.A. waterboarded him 183 times in March 2003, and threatened to kill his children while imprisoning him in a secret jail — at the hands of the government.

What happens in his case particularly matters, because President Obama has declined to pursue criminal charges against officials of George W. Bush’s administration for torture and other illegal conduct as part of the war on terror, declaring that the United States must “look forward, as opposed to looking backwards.” His administration declined not only to bring criminal prosecutions, but also to undertake a comprehensive investigation into torture. In contrast, a Senate committee is about to release a long-awaited summary of a 6,200-page “torture report,” after years of legal review and redactions.

The absence of accountability for those who encouraged and conducted torture leaves the criminal sentencing of convicted terrorists as one of the few tools, however imperfect, that remain for addressing past abuses of law, and restoring America’s reputation for dedication to the norms of international law. If convicted, Mr. Mohammed should be spared, because his execution — after years of mistreatment in a series of secret C.I.A.-run prisons before he was moved to Guantánamo — would send a disastrous message about impunity for torture and about the rule of law.