A U.S. judge has ruled that a former detainee at the U.S. military prison at Guantanamo Bay, Cuba, can stand trial in a civilian court.

U.S. District Court Judge Lewis Kaplan said Tuesday in New York that the United States did not violate Ahmed Khalfan Ghailani's right to a speedy trial by detaining him for five years.

Ghailani, a Tanzanian, will be the first Guantanamo detainee to be prosecuted in a U.S. civilian court.  He faces charges related to the 1998 bombings of the U.S. embassies in Kenya and Tanzania that killed 224 people, including 12 Americans.

Judge Kaplan said Ghailani's rights were not violated because he was held in the interest of U.S. national security, and not in an effort to boost the chances of winning a conviction.

Earlier this month, the judge rejected Ghailani's claims that he could not stand trial because he suffers from post-traumatic stress disorder.

Ghailani was captured in Pakistan in 2004.  He was held at Guantanamo from 2006 until June of last year, when he was transferred to the United States.  Ghailani has pleaded not guilty to murder and conspiracy charges.

Authorities have said he was an aide to al-Qaida leader Osama bin Laden.

Separately Tuesday, a three-judge panel ruled that another Guantanamo Bay detainee linked to al-Qaida should not be freed.

One of the appeal court judges said there was ample evidence Mohammed al-Adahi was part of the terror organization.

Tuesday's ruling reversed an earlier decision by a U.S. district court judge that al-Adahi should be released.