A federal grand jury on Wednesday indicted a former National Security Agency contractor for allegedly stealing vast quantities of government records, including top-secret information on military operations, for up to 20 years.

Harold “Hal” Martin III, 52 years old, was charged with willful retention of national defense information and faces up to 10 years in prison for each of 20 counts.

The...