The U.S. government had produced “snippets of information from various sources, out of context, to weave together a narrative of terrorist ideation,” a Florida judge said Friday, ordering the release of Marcus Dwayne Robertson, an Orlando-based Islamic scholar who stood accused of supporting terrorism.

Robertson, also known as “Abu Taubah,” had been incarcerated since 2011 on charges of tax fraud and illegal gun possession. After his arrest and subsequent conviction on those charges, prosecutors sought to add a terrorism enhancement to his sentence, a sentencing guideline modification that would have sent the Islamic scholar to prison for up to 20 years.

Instead, following the judge’s rejection of the enhancement, he was sentenced to time served and ordered released immediately.

Robertson’s case attracted national attention after prosecutors attempted to argue earlier this year that the contents of his book collection constituted evidence of his connection to terrorism. Prosecutors singled out roughly 20 titles from the more than 10,000 e-books Robertson owned, highlighted a selection of controversial passages, and used that to argue that he should be sentenced as though he were a terrorist.

None of Robertson’s charges — conspiracy to file a false tax return and possession of a firearm by a convicted felon — were terrorism offenses.

In a memorandum issued along with his decision yesterday, Judge Gregory A. Presnell strongly repudiated the government’s argument that Robertson’s book collection proved a connection to terrorism. “[T]here was no evidence produced that Robertson ever accessed these particular documents, much less that he took their extremism to heart,” Presnell wrote, noting that even had Robertson read the books in question, it would not have constituted evidence of terrorism.

“The government has never disputed Robertson’s claim of being an Islamic scholar,” the judge continued. “It is not at all remarkable for an Islamic scholar to study, among many, many others, the writings of Islamic extremists.”

The memorandum concluded by describing the sum of the government’s terrorism allegations against Robertson as “woefully inadequate,” adding that the government had “not even come close to proving …. Robertson’s relatively minor income tax fraud was intended to promote a federal crime of terrorism.”

In his closing remarks at Friday’s sentencing hearing, Presnell also stated that he had received “hundreds of emails” in the past few weeks from anti-Muslim activists urging him to impose a harsh sentence on Robertson, an unprecedented experience in his judicial career. Disputing a claim he says was made in many of these emails — that U.S. courts were excessively lenient towards accused Muslim terrorists — Presnell stated that “our courts have actually been quite harsh” in post-9/11 terrorism cases.

“In America, everyone has a right to say and believe what they want, within the bounds of the law,” Presnell said, before instructing that Robertson should be processed and freed from custody by end of day.

Speaking outside the courthouse following the ruling, Robertson’s lawyer Daniel Broderson blasted the government’s tactics in the case. “At no point did the government ever have any actual evidence [Robertson] advocated terrorism, so they attempted to use his library of books as a backhanded way of branding him as a terrorist,” Broderson said. “He spent four years in prison, two years of it in isolation, over a prosecution that was both unfounded and that completely ran afoul of the first amendment.”

Hassan Shibly, an attorney with the Council on American-Islamic Relations who had advocated on behalf of Robertson and met with him in prison, cited the judge’s ruling as a rare positive legal precedent in post-9/11 terrorism prosecutions. “This is a huge blow to the FBI’s attempts to criminalize first amendment protected activity and maliciously entrap and prosecute American Muslims,” Shibly said. “We repeatedly warned the U.S. Attorney’s office that their charges were baseless and would be thrown out by any fair judge. We were proven right, and they should frankly be ashamed of themselves today.”

Robertson’s case began in 2011 after Jonathan Jimenez, a young acquaintance of Robertson’s from New York, came to stay with him and his family in Orlando. Jimenez, who had been struggling with drug problems and mental illness, had been invited to stay at Robertson’s home in an effort to help him straighten out his personal problems and further his religious studies. While staying with Robertson, Jimenez was also separately befriended by an undercover government informant, to whom he began making statements suggesting that Robertson had been grooming him to go abroad and conduct violent jihad.

Jimenez’s statements, which he later recanted to authorities, were the only evidence besides Robertson’s book collection that the prosecution produced in its effort to tie him to terrorism. Jimenez is presently serving a 10-year prison sentence for making false statements to federal officials.

Robertson’s case had also been clouded by allegations that he had worked abroad in the past as a covert operative on behalf U.S. law enforcement and intelligence agencies, a claim the government at least partially confirmed. On April 30, a closed hearing was held to review details of Robertson’s alleged cooperation.

Speaking to The Intercept after his release, Robertson alleged that the government had attempted to use his case to establish a precedent for equating ordinary Muslim practices and scholarship with terrorism. “They’re trying to find an indirect way to sentence people with non-terrorism charges as though they’d committed terrorism offenses, without having to provide the preponderance of evidence that is normally required in such cases,” he said. “You own a few books and some guy tells an informant you said something, and suddenly that is legal basis enough to sentence you to prison for decades.”

Robertson, who was held in solitary confinement for several years of his imprisonment, says that while he is happy to be free from prison and reunited with his family, his case was handled unjustly and maliciously prosecuted by the government.

“I lost all those years, in jail, in terrible conditions, away from my family,” he said. “After all that, they couldn’t produce one single statement from me that supported terrorism.”