NEW YORK — The first, and possibly the last, Guantanamo detainee to have a U.S. civilian trial was sentenced to life in prison Tuesday for his role in the 1998 U.S. embassy bombings in Africa, a case that nearly unraveled when the defendant was convicted on just one of more than 280 counts.

Ahmed Ghailani, who served as Osama bin Laden’s cook and bodyguard after the bombings in Tanzania and Kenya, sought leniency, claiming he was tortured at a secret CIA detention site after his arrest in Pakistan seven years ago.

But U.S. District Judge Lewis A. Kaplan imposed the maximum sentence, saying that whatever Ghailani suffered “pales in comparison to the suffering and the horror” caused by the nearly simultaneous attacks, which killed 224 people and injured thousands more.

Ghailani, 36, was convicted last month of conspiring to destroy government buildings. Prosecutors said he bought a truck used in the Tanzanian attack, stored and concealed detonators, sheltered an al-Qaida fugitive and delivered hundreds of pounds of TNT to the African terror cell.

His trial at a lower Manhattan courthouse had been viewed as a test for President Barack Obama’s aim of putting other terror detainees – including self-professed Sept. 11 mastermind Khalid Sheik Mohammed – on trial on U.S. soil. His hands are tied, however – at least in the short term – because lawmakers have prohibited the Pentagon from transferring detainees to the U.S.

The prosecution of Ghailani is considered a success by supporters of civilian trials for detainees at the U.S. Navy base in Guantanamo Bay, Cuba. Critics, however, say it showed that such trials are too risky.

Attorney General Eric Holder said the sentencing “shows yet again the strength of the American justice system in holding terrorists accountable.”

But House Judiciary Committee Chairman Lamar Smith, R-Texas, called the case “a near disaster” because Ghailani was only convicted of one count.

Guantanamo once held nearly 800 detainees, mostly suspected militants captured in and around Afghanistan. Most have been released to other countries but about 170 remain. Five detainees have been convicted at Guantanamo.

Ghailani, wearing a blue dress shirt and showing no emotion, chose not to speak in the packed courtroom Tuesday. Before sentencing he bowed his head, closed his eyes and gripped the edge of the defense table with both hands as survivors and victims’ loved ones spoke behind him – some in tears, many asking the judge to show no mercy.

“The pain is with me every day,” said Sue Bartley, who lost her husband, Julian Leotis Bartley Sr., then U.S. consul general to Kenya, and her son, Julian “Jay” Bartley Jr. They were among 12 Americans killed in the bombings.

James Ndeda, a Kenyan who suffered a skull fracture and chronic eye and back problems in that country’s bombing, said he “would sentence Ghailani to hell.” As an alternative, he told Kaplan, “I believe one year for each death is a fair sentence.”

In seeking a life sentence, prosecutors cited confessions – none heard by jurors – that Ghailani gave following his arrest in Pakistan in 2004 as proof he was a fixer for the al-Qaida cell that hatched the plot.

The defense said a harsh sentence would be unfair because Ghailani had been traumatized by the CIA’s “enhanced interrogation techniques.” They wrote, “Regardless of what euphemism is used, Ahmed Ghailani was tortured at the hands of the United States government.”

Defense attorneys argued that Ghailani was a dupe for al-Qaida operatives. They admitted that Ghailani did chores for the plotters, but claimed he deserved leniency because he didn’t learn about the goal of the al-Qaida conspiracy until after it succeeded – and was horrified by the results.

His lawyers cited his remarks at a military tribunal in 2007, when he said he was “sorry for what happened to those families who lost . . . their friends and their beloved ones.”

Defense attorney Peter Quijano argued that Ghailani also deserved credit for his cooperation, saying he had provided U.S. authorities with “intelligence and information that arguably saved lives, and I submit that is not hyperbole.”

Prosecutors countered that Ghailani was aware of the plan, chose not to warn authorities and was worried most that one of the men would perish in the suicide attack.