This article was produced in partnership with the Pulitzer Center on Crisis Reporting.

GUANTÁNAMO BAY, Cuba — On the witness stand was James E. Mitchell, a psychologist and architect of the Bush-era interrogation program that had inflicted torture on prisoners held in secret C.I.A. prisons after the Sept. 11, 2001, attacks.

Defiantly, he described how the program came about and why in his view it was necessary, growing emotional only when recounting how he came to the conclusion that it was his patriotic duty to personally implement the techniques he had devised.

Sitting yards from him in the military courtroom built specifically for their death-penalty trial were the five men accused of helping plot the attacks. All of them had been subject to the methods developed by Dr. Mitchell. Their alleged leader, Khalid Shaikh Mohammed, was waterboarded 183 times in March 2003 by a team including Dr. Mitchell. They sat impassively as he testified at a pretrial hearing in their case.

It was an extraordinary moment in the slow-moving justice system set up to try foreign prisoners of the war on terror, with American lawyers for defendants who were tortured more than a decade and a half ago flipping the script to question an interrogator from the so-called black sites.