A former National Security Agency contractor who stored two decades’ worth of classified documents at his Maryland home was sentenced Friday to nine years in prison.

Harold Martin, 54, apologized before he was sentenced in Baltimore’s federal court to a theft prosecutors called “breathtaking” in scope.

“My methods were wrong, illegal, and highly questionable,” Martin told Judge Richard Bennett.

The punishment was in line with the nine-year sentence called for under his plea agreement, in which he admitted guilt to a single count of wilful retention of national defence information.

“This case is enormously significant not only for the Justice Department but also for the intelligence community,” Robert Hur, the United States Attorney in Maryland, told The Associated Press in an interview before the sentencing.

“In any case where you have someone who holds a security clearance at the level that Mr. Martin did and chooses to betray that public trust in such a profound way, it puts national security at risk.”

The sentencing resolves a mysterious case that broke into the open in 2016, when FBI agents conducting a raid found a massive trove of stolen government documents inside Martin’s home, car and storage shed.

The information spanned from the mid-1990s to the present and included personal details of government employees and “Top Secret” email chains, handwritten notes describing the NSA’s classified computer infrastructure, and descriptions of classified technical operations.

Prosecutors initially said 50 terabytes had been found, though Hur said that estimate had been revised significantly downward.

A former naval officer, Martin was an employee of Booz Allen Hamilton, an IT consulting firm.

Not comparable to Snowden, defence says

The case attracted particular attention since the raid took place just weeks after a mysterious Internet group calling itself the Shadow Brokers surfaced online to advertise the sale of hacking tools stolen from the NSA.

The U.S. believes that North Korea and Russia were able to capitalize on stolen hacking tools to unleash punishing global cyberattacks.

Prosecutors never linked Martin to the Shadow Brokers or charged him in the theft. Hur said there was no evidence he had ever transmitted classified information to anyone. But prosecutors say he nonetheless jeopardized national security through habitually taking home secret and classified government documents and carelessly storing them.

Defence lawyers, meanwhile, described Martin as a compulsive hoarder who never betrayed his country. One of his lawyers, James Wyda, said Martin’s tendencies did not reflect “spycraft” and resisted any efforts to compare him to fellow former NSA contractor Edward Snowden, who is accused of disclosing classified information.

But Hur said that characterization minimized the crime.

“This isn’t just hoarding,” Hur told the AP. “It isn’t like wandering into someone’s house and finding stacks of newspapers or library books or junk. This is highly classified information, the compromise of which is going to do grave damage to national security.”