US prosecutors say they will file espionage charges against a private contractor for the National Security Agency suspected of stealing an “astonishing quantity” of classified information.

Harold Martin III was arrested on August 27 in Maryland and poses a “grave danger” to the United States, prosecutors wrote in a filing ahead of a detention hearing set for Friday in Baltimore.

Martin, who has now been fired, worked for Booz Allen Hamilton — the same firm that hired the NSA whistleblower Edward Snowden.

Martin was entrusted to work with classified information for several government agencies and allegedly had been stealing information since 1996.

“The defendant violated that trust by engaging in wholesale theft of classified government documents and property — a course of felonious conduct that is breathtaking in its longevity and scale,” prosecutors wrote.

They said Martin had swiped at least 50,000 gigabytes of information, though not all of it was classified.

One single gigabyte is enough space to store about 10,000 pages of documents containing images and text.

“The defendant was in possession of an astonishing quantity of marked classified documents which he was not entitled to possess, including many marked (secret),” prosecutors said.

Some of the documents “appear” to contain national defence information and Martin allegedly kept the files in his car and lying around his Maryland home.

Investigators also allegedly found an “arsenal” of 10 firearms including an assault rifle.

“The government anticipates that the charges will include violations of the Espionage Act, an offence that carries significantly higher statutory penalties and advisory guideline ranges than the charges listed in the complaint,” prosecutors wrote.

Martin’s lawyers have previously said he loves his family, and said there was no evidence he intended to betray his country.

Martin does not appear to have a valid passport and investigators have not said he sent information to foreign governments.

But prosecutors noted: “The defendant has also communicated online with others in languages other than English, including in Russian.”

Booz Allen has said it reached out to offer full co-operation with the authorities as soon as it learned of the arrest, and quickly fired Martin.

The arrest came after investigators began looking into the theft of source code used by the NSA to hack adversaries’ computer systems, such as those of Russia, China, Iran and North Korea.

Such access would enable the NSA to plant malware in rivals’ systems and monitor — or even attack — their networks.

The case is an embarrassing new blow for both the NSA and Booz Allen, which the New York Times said helps build and operate many of the NSA’s most sensitive cyber operations.

Former NSA contractor Snowden has been living in Russia since shortly after leaking documents revealing the scope of the agency’s monitoring of private data.