The agency began amassing databases of “metadata” — logs of all telephone calls collected from the major carriers and similar data on e-mail traffic. The e-mail program was halted in 2011, though it appears possible that the same data is now gathered in some other way.

The documents show that America’s phone and Internet companies grew leery of N.S.A. demands as the years passed after 9/11, fearing that customers might be angry to find out their records were shared with the government. More and more, the companies’ lawyers insisted on legal orders to compel them to comply.

So the N.S.A. came up with a solution: store the data itself. That is evidently what gave birth to a vast data storage center that the N.S.A. is building in Utah, exploiting the declining cost of storage and the advance of sophisticated search software.

Those huge databases were once called “bit buckets” in the industry — collections of electronic bits waiting to be sifted. “They park stuff in storage in the hopes that they will eventually have time to get to it,” said James Lewis, a cyberexpert at the Center for Strategic and International Studies, “or that they’ll find something that they need to go back and look for in the masses of data.” But, he added, “most of it sits and is never looked at by anyone.”

Indeed, an obscure passage in one of the Snowden documents — rules for collecting Internet data that the Obama administration wrote in secret in 2009 and that the Foreign Intelligence Surveillance Court approved — suggested that the government was concerned about its ability to process all the data it was collecting. So it got the court to approve an exception allowing the government to hold on to that information if it could not keep up. The rules said that “the communications that may be retained” for up to five years “include electronic communications acquired because of the limitation on the N.S.A.’s ability to filter communications.”

As one private expert who sometimes advises the N.S.A. on this technology put it: “This means that if you can’t desalinate all the seawater at once, you get to hold on to the ocean until you figure it out.”