A former National Security Agency contractor has pleaded guilty to charges that he stole an enormous amount of classified data and kept it at his Maryland home.

Harold Martin, a former NSA contractor, had pleaded guilty to 1 count of unauthorized and willful retention of national defense information as part of a plea deal for what might be the single largest theft of US government secrets in history. The plea deal dropped the remaining 19 charges and recommends a nine-year prison sentence and three years of supervised release.

"It's time to close Pandora's box," Martin told a federal judge in Baltimore on Thursday. He will be sentenced in July.

Former NSA contractor Hal Martin is expected to plead guilty in federal court this afternoon. He’s accused of the largest security breach in US intelligence history. Police found millions of pages in classified documents when they raided his home in Glen Burnie in 2017 @wjz pic.twitter.com/CmvHq1gjzq — Mike Hellgren (@HellgrenWJZ) March 28, 2019

​For nearly two decades, Martin took his work home with him, accumulating nearly 50 terabytes of classified files in his Glen Burnie home, near Baltimore. Embarrassingly, the US intelligence state remained blissfully unaware of this massive leak until August 2016, when researchers at security software company Kaspersky Labs alerted the US government about some odd messages they'd received and traced back to Martin.

During the trial, Martin's defense argued he was an obsessive hoarder, a "voracious reader" who was "committed to excel at his job," journalist Kim Zetter, who broke the story in Politico in January, told Sputnik.

Because of an unfortunate serendipity, Zetter said, officials judged Martin to be part of the "Shadow Brokers" hacking group, which had begun posting stolen NSA cyber tools online at nearly the exact same time as Martin's mysterious messages were received by Kaspersky. She wouldn't dismiss the idea that he might have been set up by a talented hacker from the group.