In the first case of its kind, U.S. District Judge Richard J. Leon said the government's evidence linking the five Algerians to al Qaeda was not credible as it came from a single, unidentified source. Therefore, he said the five could not be held indefinitely as enemy combatants and should be released immediately.
"To allow enemy combatancy to rest on so thin a reed would be inconsistent with the court's obligation," Leon told the crowded courtroom.
As a result, "the court must and will grant the petitioners and order their release," he said.
CBS News legal analyst Andrew Cohen says the suspects in question are not the dangerous terrorists the Bush administration has been warning Americans about since 9/11. He added that the ruling would also not set a legal precedent for releasing suspected terrorists who are a true threat.
"These men were far from the worst-of-the-worst, or the sorts of 'killers' that the White House has called the detainees at Guantanamo Bay," Cohen said. "So in many ways this is not a true test of the power of the civilian courts to release terror suspects. In other words, the ruling doesn't mean anything to or for Khalid Sheik Mohammed or Ramzi Binalshibh, true terror kingpins."
As for the sixth Algerian, Belkacem Bensayah, Leon said there was enough reason to believe he was close to an al Qaeda operative and had sought to help others travel to Afghanistan to join the terrorists' fight against the United States and its allies.
One of the men to be released is Lakhdar Boumediene, whose landmark Supreme Court case last summer gave the Guantanamo detainees the right to challenge their imprisonment.
The Algerians' attorneys said they would appeal Bensayah's detention but hugged each other and colleagues in congratulations after Leon's ruling.
"It's a relief," said attorney Robert C. Kirsch.
Although it took more than seven years, reports CBS News correspondent Wyatt Andrews, defense lawyers still called it a victory for American justice.
"It shouldn't have taken this long," said Stephen Olesky. "People locked into the government system based on mistakes that absolutely is what I believe happened.
The Justice Department complained it had to withhold its most secret evidence because of a court order to share it with the defense, Andrews reports. But after a weeks-worth of other secret testimony against the men, a federal judge appointed by President Bush has said there wasn't a case.
The Bosnian government already has agreed to take back the detainees, all of whom emigrated there from Algeria before they were captured in 2001.
Justice spokesman Peter Carr said the department is pleased that Bensayah will remain at Guantanamo, but "we are of course disappointed by, and disagree with, the court's decision that we did not carry our burden of proof with respect to the other detainees."
Leon also urged senior Justice Department leaders and high-level officials at other government agencies involved in the case not to appeal his ruling. Later Thursday, the department said it had not decided whether it would.
Leon's ruling is not binding says Cohen, which leaves plenty of room for a government appeal.
"The men aren't going to be immediately released," Cohen says. "We are going to see a whole new round of appeals now and it's not at all clear that the appeals courts are going to see this issue the way the trial judge did.
"Still, it's an embarrassing if not unexpected blow to the White House and the Pentagon. But it's also a highly symbolic ruling - the first time the courts have ordered the release of Gitmo detainees over the objections of the government - since a Supreme Court ruling last year that permitted this sort of judicial review."
Leon said the five Algerians already have been improperly held for seven years, and deserve to go home. An appeal could delay their release for up to another two years, Leon said.
"This is a unique case," Leon said, trying to assuage any Justice Department fears that hundreds of other detainees also could be released based on Thursday's ruling. "Few if any others will be factually like it. Nobody should be lulled into a false sense that all of the ... cases will look like this one."
The case marks the first ruling since the Supreme Court cleared the way last June for civilian courts to hear challenges by detainees being held indefinitely without charges.
It largely hinged on Leon's definition of an enemy combatant, which he said included al Qaeda or Taliban supporters who directly assisted in hostile acts against the United States or its allies.
Much of the evidence against the Algerians is classified and could not be discussed during the few open court hearings in the two-week trial, or even with the detainees themselves. The detainees listened to Thursday's ruling through a translated telephone conference call, but could not be heard during the nearly one-hour hearing.
The government initially detained Boumediene and the other Algerians on suspicion of plotting to bomb the U.S. Embassy in Sarajevo, Bosnia-Herzegovina in October 2001. They were transferred to Guantanamo in January 2002.
The Justice Department last month backed off the embassy bombing accusations but said the six men were caught and detained before they could an international terrorist fight against the United States and its allies. The Justice Department said it needed to be proactive against threats, especially in the months after the Sept. 11, 2001, attacks on New York, Washington and Pennsylvania.
The detainees' lawyers denied the men ever planned to join the battlefield. Even if they had, the lawyers argued, they did not fit Leon's definition of an enemy combatant because they never joined the terrorist fighters.
The cases of more than 200 additional Guantanamo detainees are still pending, many in front of other judges in Washington's federal courthouse.