A former National Security Agency contractor accused in a massive theft of classified information will remain in custody as prosecutors continue building a criminal case against him, a federal judge ruled Friday.

U.S. Magistrate Judge A. David Copperthite agreed with prosecutors that Harold T. Martin III of Glen Burnie, Md., represented a flight risk if released and said there was no doubt that the top secret information he was accused of stealing over two decades is something "this country's enemies would love to explore."

Martin's lawyers foreshadowed their upcoming defense, describing him as a "compulsive hoarder" and saying there was no evidence he ever shared the information with a foreign country or even intended to do so.

"He's not Edward Snowden," said James Wyda, the federal defender representing Martin, referring to the former NSA contractor who three years ago disclosed to journalists secret information about government surveillance programs.

Wyda said Martin, a former U.S. Navy lieutenant, never intended to harm his country and was instead a "voracious" learner who got carried away over the years as he took home documents in a perhaps misguided effort to be as skilled at his job as he could be. He suggested Martin grappled with mental health issues.

"This was not spycraft behavior," Wyda said. "This is not how a Russian spy or something like that would ever conduct himself."

"This," he added, "was the behavior of a compulsive hoarder."

The Justice Department presented a vastly different portrait.

Prosecutors have said FBI agents who searched Martin's home and car in August found evidence of a "breathtaking" theft of top secret government information. Investigators found records dated from 1996 to 2016, seized dozens of computers and digital storage devices and, all told, recovered some 50 terabytes of information — or enough to fill roughly 200 laptops. A substantial amount of that information, prosecutors said, was highly classified.

"There is no reason to believe that the defendant would have ever stopped but for the intervention of law enforcement," Assistant U.S. Attorney Zachary Myers said.

Myers said Martin's knowledge of secret government programs could make him a "high-value recruitment target from foreign intelligence services." Prosecutors have said he has been communicating online in foreign languages, including Russian.

A complaint unsealed earlier this month charged Martin with theft of government property and unauthorized removal and retention of classified materials, which together carry a combined maximum of 11 years in prison. But Myers said in court Friday that the Justice Department has evidence to bring additional charges under the Espionage Act, which would expose Martin to far more severe penalties if convicted.

Though authorities are still reviewing the records to determine the appropriate classification level, they say they already have found many that are clearly marked as classified — including one top secret email chain that appeared to have been printed off Martin's government account.

The document contained handwritten notes on the back regarding the NSA's classified computer infrastructure and descriptions of classified technical operations. The notes include basic concepts of classified operations, as if written for an "audience outside of the Intelligence Community unfamiliar with the details of its operations," prosecutors wrote in a court filing.

Another classified document marked as "Top Secret/Sensitive Compartmented Information" concerned "specific operational plans against a known enemy of the United States and its allies," the Justice Department alleged.

Martin was arrested around the same time federal officials acknowledged an investigation into a cyberleak of purported hacking tools used by the NSA. Those documents were leaked by a group calling itself the "Shadow Brokers," but there is nothing in court filings — and nothing said in court Friday — that connects Martin to that group.

Wyda, his lawyer, said the government had presented no evidence that ties Martin to any foreign power. And he said it was unfair to keep Martin in custody on a speculative concern that he might somehow come in contact with another nation.

"This sounds like something I would have heard in a presidential debate," he said. "This is beneath us."

He said after court that he and Martin's family were disappointed in the judge's ruling and would appeal.

Martin, like Snowden, worked as a contractor for Booz Allen Hamilton. The company has said he's since been fired.