WASHINGTON—A former National Security Agency contractor amassed at least 500 million pages of government records, including top-secret information about military operations, by stealing documents bit by bit over two decades, the Justice Department alleged in a court filing submitted Thursday.

Prosecutors in August arrested and charged Harold “Hal” Martin III, of Glen Burnie, Md., with theft of government property and unauthorized removal or retention of classified documents. The case was kept under seal until earlier this...