(CNN) -- A U.S. district court judge in the District of Columbia Monday ordered the United States to release a detainee held for nearly nine years at the military prison in Guantanamo, Cuba.

Judge Henry H. Kennedy Jr. ruled that the federal government had "failed to demonstrate that the detention of [Adnan Farhan Abd Al Latif] is lawful."

Kennedy heard oral arguments on the matter in early June.

Significant portions of Kennedy's 28-page ruling -- including some whole pages -- are redacted. But the document makes clear that Kennedy agreed with Latif's arguments that documents and other evidence used against him were not reliable and that the government's belief that a man he met with was an al Qaeda recruiter is incorrect.

"Latif's story is not without inconsistencies and unanswered questions," Kennedy wrote, "but it is supported by corroborating evidence provided by medical professionals and it is not incredible.

"The Court does not accept respondents' contention that Latif must be lying because he has told more than one cover story."

The differences, he wrote, "may be no more than misstatements or mistranslations; even if the details of Latif's story have changed over time, for whatever reason, its fundamentals have remained the same."

Latif, a Yemeni who is now 34, was captured by Pakistani authorities in late 2001. He was transferred to Guantanamo in January 2002. When he was 18, Latif suffered head injuries in a car accident, and his treatment was paid for by the Yemeni government. Latif said the treatment was incomplete, and he "sought charitable assistance."

In 2000, he met a man named Ibrahim, according to the court ruling, who promised him free medical care in Pakistan. The federal government argued that Ibrahim was actually an al Qaeda recruiter named Abu Khalud, "who encouraged Latif to go to Afghanistan to receive military training and/or fight jihad."

Although the government used interrogation responses from other prisoners to bolster its claim that Ibrahim was Abu Khalud, Latif noted that no other detainee ever reported seeing him on the battlefield or at an al Qaeda safe house or training camp. Also, a 2004 Defense Department determination that Latif "is not known to have participated in combatant/terrorist training."

Kennedy agreed that many of the "incriminating statements" provided by the government lacked "corroborating evidence," that "there is serious question" about the accuracy of some of the evidence against Latif and that Latif "has presented a plausible alternative story to explain his travel."

"Because respondents have not demonstrated by a preponderance of the evidence that Latif was part of al Qaeda or an associated force, the Court concludes that his detention is unlawful," the judge wrote.