(Reuters) - A former U.S. National Security Agency contractor, portrayed as an eccentric hoarder by his lawyers, pleaded guilty in a Baltimore, Maryland court on Thursday to stealing classified documents in a deal likely to put him in prison for nine years.

Harold Martin, 54, who worked for several private firms and had clearances to access top secret information, was arrested over two years ago for what may have been the biggest breach of classified information in history.

When Federal Bureau of Investigation agents raided his home south of Baltimore in 2016 they found stacks of documents and electronic storage devices amounting to 50 terabytes of files, including classified ones, prosecutors said.

U.S. Department of Justice prosecutors said in a statement that Martin’s actions risked the disclosure of top secret information to America’s “enemies.” One of their allegations was that Martin talked online with people in Russian and other languages but they never found proof he shared stolen information with anyone.

His lawyers said he was a hoarder who liked to take work home with him.

“His actions were the product of mental illness. Not treason,” lawyers Deborah Boardman and James Wyda said in a statement.

Martin and the government agreed that if the federal court in Baltimore accepted the plea agreement, he would be sentenced to nine years in prison on the charge of willful retention of national defense information, prosecutors said. Sentencing was set for July 17 by U.S. District Judge Richard Bennett.