A gang leader-turned-radical-Muslim imam considered so dangerous he was kept in shackles and assigned his own guard while he was held in a Florida prison for four years has been freed by a federal judge who said he believes Marcus Dwayne Robertson is a "very bad man," but that federal prosecutors were "woefully inadequate" in making their case for keeping him behind bars.

Robertson, a charismatic former U.S. Marine trained in special operations, once headed a murderous New York gang dubbed “Ali Baba and the 40 Thieves” before resurfacing as a radical imam in Florida who federal sources say radicalized young men and sent them overseas to join terrorist groups. While locked up in the federal wing of the John E. Polk Correctional Facility in Seminole County on gun and tax fraud convictions, Robertson was shackled and held in isolation with an armed guard assigned to him exclusively. Whenever he was transported to court, a seven-car caravan of armed federal marshals escorted him.

Yet efforts by federal prosecutors to tack on another 10 years to his sentence, based on enhanced terrorism charges under the Foreign Intelligence Surveillance Act, were not persuasive enough for U.S. District Judge Gregory Presnell, who on Friday freed Robertson with time served.

“By all accounts, Marcus Dwayne Robertson was a very bad man, one of the leaders of a criminal gang that committed violent armed robberies in the early 1990s. … Robertson personally participated in more than a dozen armed robberies, and shot and killed several men,” wrote Presnell in a June 25 sentencing statement.

“Notwithstanding the vast investigative resources of the United States, and years of effort, the prosecution’s proof is woefully inadequate.”

- US District Judge Gregory Presnell

However, Presnell said prosecutors took snippets of information from various sources out of context to make their case that Robertson is a terrorist leader, and never proved their case.

“Notwithstanding the vast investigative resources of the United States, and years of effort, the prosecution’s proof is woefully inadequate,” Presnell wrote. “The Court finds that the prosecution has not even come close to proving by a preponderance of the evidence that Robertson’s relatively minor income tax fraud was intended to promote a federal crime of terrorism.”

Prosecutors would not comment on the case, possible plans to appeal the judge’s sentence or whether they may seek additional charges against Robertson. They argued during sentencing proceedings that Robertson “is still an extremist, just as he was in the early 1990s.”

Many of the court’s filings, including Robertson’s own testimony, remain under federal seal, which means only prosecutors, the judge and the defense can review the records. Reporters were locked out of substantial portions of the nearly three days of testimony during the sentencing proceedings, which began in April and ran through June, “due to concerns about disclosure of classified information.”

That’s because as part of his own defense, Robertson testified about his undercover work for the FBI, which reportedly involved documenting terrorists’ plans and networks in Africa, Egypt and the United States.

Robertson, those familiar with the case said, has information that could be potentially dangerous to the U.S. if exposed. The information was acquired along his unlikely journey from U.S. Marine Corps 2nd Force Reconnaissance Company field radio operator, beginning in May 16, 1986, to his status now as founder and imam at the Orlando-based Fundamental Islamic Knowledge Seminary.

Released from active duty in March 1990 as a conscientious objector, Robertson had training in radiotelegraph, scuba diving, marksmanship, parachuting, terrorism counteraction, surveillance, infantry patrolling and finance. A year later, he showed upon federal law enforcement radar when he joined with other former Muslim security guards to form a robbery gang they called the "40 Thieves." With Robertson as the leader known as "Ali Baba,” they robbed more than 10 banks, private homes and post offices at gunpoint, shot three police officers, and attacked one cop after he was injured by a homemade pipe bomb.

During the same period, Robertson served as a bodyguard to Omar Abdel Rahman, nicknamed the “Blind Sheik,” who led the terrorist group that carried out the 1993 bombing of the World Trade Center. Robertson also donated more than $300,000 in stolen funds to mosques he attended, prosecutors claim.

After he was arrested in 1991 along with most of the other members of the gang, prosecutors cut a deal with Robertson.

After serving four years in prison, Robertson went undercover for the FBI between 2004 and 2007 to document terrorists’ plans and networks in Africa, Egypt and the United States, but according to a source familiar with Robertson’s history, Robertson was thrown out of the program in Feb. 8, 2007 after he attacked his CIA handler in Africa.

Undeterred, Robertson quickly reinvented himself, founding his mosque and religious school in 2008 and taking the Muslim name Abu Taubah. He traveled the world, teaching at universities, including some in the United States, recruiting an extensive network of followers.

Under Islamic law, the Brooklyn-born Robertson married two women, Zulaika and Itisha Wills. Between them, and children he fathered outside these marriages, Robertson has 15 children.

The federal government had continued to keep a close watch on Robertson. Through wiretaps in 2011, the federal government documented interactions between Robertson and one of his students, Jonathan Paul Jimenez, who Robertson allegedly instructed to file false tax returns to obtain a tax refund to pay for travel to Mauritania, Northwest Africa, for study and violent jihadist training.

Jimenez, who reportedly knew Robertson for 11 years and, by his own admission, trained with the imam for a year in preparation for his travel to Mauritania, where he would study and further his training in killing, suicide bombing, and identifying and murdering U.S. military personnel, pleaded guilty Aug. 28, 2012, to making a false statement to a federal agency in a matter involving international terrorism and conspiring to defraud the IRS. He was sentenced April 18, 2013, to 10 years in federal prison.

Robertson was arrested on a firearms charge in 2011 and pleaded guilty in January 2012. On March 14, 2012, federal authorities charged Robertson with conspiring to defraud the IRS of more than $5,000, a charge he was convicted for after a bench trial in December 2013.

In seeking enhanced terrorism charges during sentencing for the two crimes, prosecutors said Roberston has been involved with terrorism activities, “…focused on training others to commit violent acts as opposed to committing them himself” … “overseas instead of inside the United States.”

Robertson, who could not be reached for comment, denied in court and in postings on social media being involved with terrorist activities.

Prosecutors introduced as evidence 20 documents authored by militant Islamic extremists found in Robertson’s possession, including “teachings by Anwar al-Aulaqi, a leader and recruiter for Al Qaeda; Abu Hamza, a cleric who encouraged fighters to join Al Qaeda and is currently serving a life sentence in federal prison on numerous terrorism charges; and Abu Muhammad al-Maqdisi, reputedly the most influential living jihadi theorist.”

In a 17-page written decision issued June 25, however, the judge said: “But what the prosecution has failed to show is that Robertson shares these extremist beliefs. The 20-or-so works were part of a 10,000-document Islamic library accessible via Robertson’s computer. There was no evidence produced that Robertson ever accessed these particular documents, much less that he took their extremism to heart.”

Robertson’s attorney Daniel Brodersen told FoxNews.com his client was “obviously delighted the judge saw that the government did not have significant proof to show he had any conduct related to terrorism.”

The government was “overzealous in the case,” Brodersen said, “because of the times we are in.”

“They pursued a case of terrorism when it did not exist,” Brodersen said.