A federal judge in New York has ruled that a defendant held for nearly five years at a secret CIA prison and at the military detention center at Guantanamo Bay, Cuba, did not have his right to a speedy trial violated and can be prosecuted for involvement in the 1998 East Africa embassy bombings. The ruling, released Tuesday, is a significant victory for the government because it closes a legal avenue to challenge prosecutions for all high-value detainees who were held by the CIA and at Guantanamo Bay, including Khalid Sheik Mohammed, the self-proclaimed mastermind of the Sept. 11, 2001, attacks. Although the government has postponed decisions on further federal prosecutions of Guantanamo Bay detainees, including Mohammed, the ruling keeps that option open. A loss would have effectively forced the government to keep all major prosecutions in military commissions, something it might yet have to do, but for political, not legal, reasons. Ahmed Ghailani, a Tanzanian, had sought to have his indictment dismissed on Sixth Amendment grounds, arguing that the government could have prosecuted him at the time of his capture in 2004 or could have questioned him for national security reasons, but that it could not legally do both. A former Islamic cleric, Ghailani was seized by Pakistani authorities after a 10-hour shootout in the Pakistani city of Gujrat in July 2004 and turned over to the United States. He was taken to several secret CIA facilities overseas before he and 13 other high-value detainees _ including Mohammed _ were transferred to Cuba in 2006. At a 2007 military hearing at Guantanamo Bay, Ghailani attempted to present himself as an unwitting participant in the embassy bombings. Federal prosecutors, however, allege that Ghailani, now 36, obtained bomb materials, scouted the embassy in the Tanzanian capital and escorted an Egyptian suicide bomber from Kenya to Dar es Salaam before the attack. The bombing in Tanzania, and another in Kenya, killed 224 people, including 12 Americans. Shortly before the attack, Ghailani, using a fake passport, fled to Afghanistan. Military prosecutors said he worked as a trainer at a terrorist camp there. He was sent to the Southern District of New York for prosecution in June 2009 by the Obama administration, its first and only transfer of a Guantanamo Bay detainee to the federal courts. A subsequent plan to transfer Mohammed and four co-defendants to New York was suspended because of intense local and congressional opposition. The Ghailani prosecution has continued and he is expected to be tried this fall. 'Although the delay of this proceeding was long and entirely the product of decisions for which the executive branch is responsible, the decisions that caused the delay were not made for the purpose of gaining any advantage over Ghailani in the prosecution of this indictment,' U.S. District Judge Lewis Kaplan ruled. 'Two years of the delay served compelling interests of national security.' Kaplan said that Ghailani's subsequent detention at Guantanamo Bay as an enemy combatant was also justified and did not infringe on his rights. In a separate decision Tuesday, a federal appeals court overturned a lower court judge's ruling that Guantanamo Bay detainee Mohammed al-Adahi be released. The three-judge panel unanimously decided that there is sufficient evidence that Adahi met with Osama bin Laden and attended an al-Qaida training camp. _ The Associated Press contributed to this report. 