Just a few months ago, in April of this year, the Guantánamo Bay detainee Salim Hamdan appeared before the Navy captain acting as his military judge, and announced that he would boycott the war-crimes trial the Bush administration had planned for him. “There is no such thing as justice here,” Hamdan said of the special tribunal constituted to try him. The judge exhorted him to have faith in American law. “You have already been to the Supreme Court,” he reminded the embittered detainee. Hamdan didn’t go for it. He told the judge that while his lawyers had gone to the highest court in the land to argue on his behalf, he’d been left behind—at Guantánamo.

Hamdan’s present makes for a bleak backdrop to his recent past, and to the Supreme Court victory achieved in his name, whose history Jonathan Mahler recounts in his new book. Few of the court’s decisions have been so legally meaningful and yet so personally meaningless.

The judicial battle began in 2004, when the Bush administration lost in its effort to indefinitely detain Yaser Esam Hamdi, an American citizen also held at Guantánamo. Rather than try him in the federal courts, the government sent Hamdi back to Saudi Arabia, where he had grown up and also held dual citizenship. But the administration presumably decided it could not afford to take the same approach with Hamdan, who has admitted to being Osama bin Laden’s driver, and who (like hundreds of other Guantánamo detainees) is not an American citizen. Instead, the administration doubled down.

As Mahler explains, however, the White House soon encountered a major obstacle: the Supreme Court. When Hamdan’s lawyers first submitted their appeal, it had been met with silence. According to the author, the press may have helped influence the justices to change their minds and take the case. A member of the defendant’s legal team, Neal Katyal, appealed to a number of reporters (including this one) for coverage. He then enlisted Milt Bearden, a famed former CIA operative, to write a New York Times op-ed urging the court to take the case. The Monday after Bearden’s article appeared, the justices announced that they had granted Hamdan’s petition.

On June 29, 2006, the court handed down its decision. Hamdan v. Rumsfeld delivered a sharp rebuff to the administration. In a majority opinion written by Justice John Paul Stevens, the Supreme Court ruled that the current tribunal lacked the power to proceed under the Uniform Code of Military Justice and the Geneva Conventions.

In response, the president enlisted Congress to approve the 2006 Military Commissions Act, which was supposed to make the military tribunals pass constitutional muster. The new law stripped detainees of their right to appeal in the federal courts via the writ of habeas corpus—a provision that the Supreme Court would eventually strike down, on June 12 of this year. Congress also went some distance toward making the trial procedures more fair (though they still fall short of the due-process protections provided by a court martial). As Mahler explains, “Detainees could no longer be kicked out of the courtroom, they would be able to see all of the evidence against them, and there was now a much stronger prohibition against the use of testimony obtained through torture.”

The ongoing push and pull between the president, Congress, and the courts is why Hamdan v. Rumsfeld matters, and why it was worth all the print and TV coverage that attended it. Yet while his lawyers will bring a fresh challenge to his detention based on the Supreme Court’s June 12 decision, Hamdan himself may well end up where he started—alone in a cell in Guantánamo, without hope of appeal or release. Meanwhile, his lawyers have argued that their client’s experience of near-solitary confinement has made him suicidal and unable to assist in his own defense.

Mahler addresses this anticlimax in his epilogue; it’s a tribute to his writing skills that the ending doesn’t overshadow the entire book. And Mahler deserves great credit for taking on this project in the first place: he has a powerful story to tell, but no straightforward cause or characters to champion. The title of the book’s last chapter, “The Heroes of Guantánamo?,” merits its question mark. Like A Civil Action, the classic of the genre, The Challenge is necessarily written in shades of gray.

Emily Bazelon is a senior editor at Slate.