When a senior FBI official told Congress the role the NSA's secret surveillance apparatus played in a San Diego terror financing case today, nobody was more surprised to hear it than the defense attorney who fought a long and futile court battle to get exactly the same information while defending the case in court.

“His lawyers – who all have security clearances – we can't learn about it until it’s to the government’s tactical advantage politically to disclose it," says New York attorney Joshua Dratel. “National security is about keeping illegal conduct concealed from the American public until you’re forced to justify it because someone ratted you out."

Lawyer Joshua Dratel.

Dratel represents Basaaly Saeed Moalin, a San Diego cab driver who was convicted in February of providing material support for a terrorist organization. Moalin raised money for the Somali militia group al Shabaab, which the State Department declared a foreign terrorist organization in 2008.

Before today the case was barely a footnote in the war on terror. But in testimony before the House Select Committee on Intelligence, FBI deputy director Sean Joyce brandished it – without saying Moalin's name – as one example of how the government's secret surveillance programs have thwarted terrorists. The FBI had investigated the San Diego man after the September 11 attacks, and found no connection to terrorist activity, Joyce said. Then in October 2007, the NSA, using the phone records it compiled with Patriot Act 215 orders, "tipped us off that this individual had indirect contacts with a known terrorist overseas," he said. "We were able to reopen this investigation, identify additional individuals through legal process and were able to disrupt this terrorist activity."

That's the end of the story, as Joyce told it. Under questioning he revealed enough to make it clear he was talking about the Moalin case, where court records show the rest of the story.

When the FBI got the case, it began spying on Moalin with a secret order from the Foreign Intelligence Surveillance Court, intercepting 1,800 phone calls amounting to “hundreds of hours” of conversations from December 2007 to December 2008, and 680 pages of emails from Moalin’s account with Microsoft’s Live.com service.

After Moalin's arrest, Dratel challenged the legality of the spying in 2011, and asked a federal judge to order the government to produce the wiretap application the FBI gave the secretive FISC to justify the surveillance. In a conventional wiretap, defense lawyers are permitted to see the affidavit used to justify the surveillance to a judge, and ask a judge to suppress evidence obtained from a wiretap issued on false information.

“Disclosure of the FISA applications to defense counsel – who possess the requisite security clearance – is also necessary to an accurate determination of the legality of the FISA surveillance, as otherwise the defense will be completely in the dark with respect to the basis for the FISA surveillance,” wrote Dratel (.pdf)

The government fought the request in a 60-page reply brief, much of it redacted as classified in the public docket. The Justice Department argued that the defendants had no right to see any of the filings from the secret court, and instead the judge could review the filings alone in chambers. "Confidentiality is critical to national security," the government wrote (.pdf)

>“National security is about keeping illegal conduct concealed from the American public until you’re forced to justify it because someone ratted you out."

“Indeed, to the Government’s knowledge, no court has ever suppressed FISA- obtained or -derived information, or held an adversarial hearing on motions to disclose or to suppress,” the government added.

The government filing also indicated that the wiretapping of Moalin began without a court order, under a provision of FISA that allowed the feds to conduct warrantless surveillance of content for up to 72 hours in an emergency, before getting authorization from the Foreign Intelligence Surveillance Court. The FISA Amendments Act has since expanded that window to seven days

“At the time of the emergency authorizations here, FISA provided that in emergency situations the Attorney General may authorize electronic surveillance and physical search without an order from the FISC,” wrote the Justice Department.

U.S. District Judge Jeffrey T. Miller rejected the defense FISA challenge in a secret opinion in June of last year; even Dratel, who has a government security clearance, was not permitted to see the order, he says. The first he learned of the NSA's role in his client's case was when Joyce disclosed it on CSPAN to argue for the effectiveness of the NSA's spying.

The cab driver and three codefendants went on to lose their jury trials, and Moalin faces up to 20 years at sentencing in September.

“We’re going to evaluate our options as to what to do now to get to the bottom of this," says Dratel.

By coincidence, Dratel also represents Sabirhan Hasanoff, who was also cited by Joyce in a surveillance success story. Hasanoff supposedly plotted to blow up the New York Stock Exchange. Hasanoff has pleaded guilty to providing material support to terrorists. But the government's own sentencing memorandum shows that the defendants called off a proposed plot on their own, without any involvement from federal authorities, and over a year before being arrested.

"There was no plot," says Dratel. "There was one guy was asked to check out a tourist site downtown. It was a year and a half before they arrested Hasanoff. So if they thought it was really a plot, what were they doing letting him run around?"

The sentencing memorandum in that case, dated May 31, confirms Dratel's statements. "Hasanoff relayed that the New York Stock Exchange was surrounded by approximately four streets that were blocked off from vehicular traffic and that someone would have to walk to the building. The Doctor [an undisclosed high-ranking al-Qaida operative] revealed that, although the information provided by Hasanoff could be used by someone who wanted to do an operation, he was not satisfied with the report, and he accordingly disposed of it."

“This casts suspicion on everything they say about these programs, and the efficacy of these programs," says Dratel. “Their notion of transparency is so tired. They have to stop lying to everybody.”

Additional reporting by David Kravets