For years, the companies had been handling requests from the FBI. Now Congress had given the NSA the authority to take information without warrants. Though the companies didn't know it, the passage of the Protect America Act gave birth to a top-secret NSA program, officially called US-98XN.
It was known as Prism. Though many details are still unknown, it worked like this:
Every year, the attorney general and the director of national intelligence spell out in a classified document how the government plans to gather intelligence on foreigners overseas.
By law, the certification can be broad. The government isn't required to identify specific targets or places.
A federal judge, in a secret order, approves the plan.
With that, the government can issue "directives" to Internet companies to turn over information.
While the court provides the government with broad authority to seize records, the directives themselves typically are specific, said one former associate general counsel at a major Internet company. They identify a specific target or groups of targets. Other company officials recall similar experiences.
All adamantly denied turning over the kind of broad swaths of data that many people believed when the Prism documents were first released.
"We only ever comply with orders for requests about specific accounts or identifiers," Microsoft said in a statement.
Facebook said it received between 9,000 and 10,000 requests for data from all government agencies in the second half of last year. The social media company said fewer than 19,000 users were targeted.
How many of those were related to national security is unclear, and likely classified. The numbers suggest each request typically related to one or two people, not a vast range of users.
Tech company officials were unaware there was a program named Prism. Even former law enforcement and counterterrorism officials who were on the job when the program went live and were aware of its capabilities said this past week that they didn't know what it was called.
What the NSA called Prism, the companies knew as a streamlined system that automated and simplified the "Hoovering" from years earlier, the former assistant general counsel said. The companies, he said, wanted to reduce their workload. The government wanted the data in a structured, consistent format that was easy to search.
Any company in the communications business can expect a visit, said Mike Janke, CEO of Silent Circle, a company that advertises software for secure, encrypted conversations. The government is eager to find easy ways around security.
"They do this every two to three years," said Janke, who said government agents have approached his company but left empty-handed because his computer servers store little information. "They ask for the moon."
That often creates tension between the government and a technology industry with a reputation for having a civil libertarian bent. Companies occasionally argue to limit what the government takes. Yahoo even went to court and lost in a classified ruling in 2008, The New York Times reported Friday.
"The notion that Yahoo gives any federal agency vast or unfettered access to our users' records is categorically false," Ron Bell, the company's general counsel, said recently.
Under Prism, the delivery process varied by company.
Google, for instance, says it makes secure file transfers. Others use contractors or have set up stand-alone systems. Some have set up user interfaces making it easier for the government, according to a security expert familiar with the process.
Every company involved denied the most sensational assertion in the Prism documents: that the NSA pulled data "directly from the servers" of Microsoft, Yahoo, Google, Facebook, AOL and more.
Technology experts and a former government official say that phrasing, taken from a PowerPoint slide describing the program, was likely meant to differentiate Prism's neatly organized, company-provided data from the unstructured information snatched out of the Internet's major pipelines.
In slide made public by the newspapers, NSA analysts were encouraged to use data coming from both Prism and from the fiber-optic cables.
Prism, as its name suggests, helps narrow and focus the stream. If eavesdroppers spot a suspicious email among the torrent of data pouring into the United States, analysts can use information from Internet companies to pinpoint the user.
With Prism, the government gets a user's entire email inbox. Every email, including contacts with American citizens, becomes government property.
Once the NSA has an inbox, it can search its huge archives for information about everyone with whom the target communicated. All those people can be investigated, too.
That's one example of how emails belonging to Americans can become swept up in the hunt.
In that way, Prism helps justify specific, potentially personal searches. But it's the broader operation on the Internet fiber optics cables that actually captures the data, experts agree.
"I'm much more frightened and concerned about real-time monitoring on the Internet backbone," said Wolf Ruzicka, CEO of EastBanc Technologies, a Washington software company. "I cannot think of anything, outside of a face-to-face conversation, that they could not have access to."
One unanswered question, according to a former technology executive at one of the companies involved, is whether the government can use the data from Prism to work backward.
For example, not every company archives instant message conversations, chat room exchanges or videoconferences. But if Prism provided general details, known as metadata, about when a user began chatting, could the government "rewind" its copy of the global Internet stream, find the conversation and replay it in full?
That would take enormous computing, storage and code-breaking power. It's possible the NSA could use supercomputers to decrypt some transmissions, but it's unlikely it would have the ability to do that in volume. In other words, it would help to know what messages to zero in on.
Whether the government has that power and whether it uses Prism this way remains a closely guarded secret.
A few months after Obama took office in 2009, the surveillance debate reignited in Congress because the NSA had crossed the line. Eavesdroppers, it turned out, had been using their warrantless wiretap authority to intercept far more emails and phone calls of Americans than they were supposed to.
Obama, no longer opposed to the wiretapping, made unspecified changes to the process. The government said the problems were fixed.
"I came in with a healthy skepticism about these programs," Obama explained recently. "My team evaluated them. We scrubbed them thoroughly. We actually expanded some of the oversight, increased some of the safeguards."
Years after decrying Bush for it, Obama said Americans did have to make tough choices in the name of safety.
"You can't have 100 percent security and also then have 100 percent privacy and zero inconvenience," the president said.
Obama's administration, echoing his predecessor's, credited the surveillance with disrupting several terrorist attacks. Leading figures from the Bush administration who endured criticism during Obama's candidacy have applauded the president for keeping the surveillance intact.
Jason Weinstein, who recently left the Justice Department as head of its cybercrime and intellectual property section, said it's no surprise Obama continued the eavesdropping.
"You can't expect a president to not use a legal tool that Congress has given him to protect the country," he said. "So, Congress has given him the tool. The president's using it. And the courts are saying 'The way you're using it is OK.' That's checks and balances at work."
Schneier, the author and security expert, said it doesn't really matter how Prism works, technically. Just assume the government collects everything, he said.
He said it doesn't matter what the government and the companies say, either. It's spycraft, after all.
"Everyone is playing word games," he said. "No one is telling the truth."
Associated Press writers Eileen Sullivan, Peter Svensson, Adam Goldman, Michael Liedtke and Monika Mathur contributed to this report.
Contact the AP's Washington investigative team at DCinvestigations@ap.org