Accusations came as Harold “Hal” Martin III’s attorneys sought unsuccessfully to have him released pending trial

The Justice Department has told a federal judge that a former National Security Agency contractor took home records containing the names of U.S. spies working undercover, information that is considered among the nation’s most sensitive and closely held secrets.

Much of the information taken by Harold “Hal” Martin III, who was arrested in August and has been charged with stealing classified information, was on computers or thumb drives, prosecutors said. But Mr. Martin also had “thousands of hard-copy documents containing...