The company built a software program specifically to scan the emails. The government's request for such information from companies is allowed under the Foreign Intelligence Surveillance Act.
"Yahoo is a law abiding company, and complies with the laws of the United States," the company said in a statement to Reuters.
In a report by CNN Money in 2014, data from Google, Facebook, Microsoft, LinkedIn, and Yahoo about the volume of requests made by the government was published. The report said Yahoo recieved requests for information from 30,000 to 30,999 accounts in the period between July and December of 2012. Yahoo went on to explain in a public post that the U.S. government limits how companies can report national security requests, requiring that they be released in ranges instead of concrete numbers.
After the report was published, Yahoo CEO Marissa Mayer called for more transparency from the NSA. The five companies in the report also called for reform of government surveillance programs in 2013 to limit the information collected.
Yahoo's decision to comply with the government's surveillance will likely be the source of much debate. Earlier this year, public opinion was split when the government asked Apple to access the information in the iPhone used in the San Bernardino terror attack.
It is unknown if any other companies were asked to turn over emails or if any other companies complied with the government's demands. Reuters' report says it's likely that many other companies were asked to do so since it would be unclear what email server a target would be using.
Former NSA subcontractor Edward Snowden urged Yahoo users to take action after the report was made public. "Use @Yahoo? They secretly scanned everything you ever wrote, far beyond what law requires. Close your account today," he tweeted Tuesday.