Yahoo built a special software program to comply with the government's request, according to Reuters.
The Sunnyvale company did not deny the report in a Tuesday statement that described itself as a company "that complies with the laws of the United States." The Department of Justice and the FBI did not immediately respond to requests for comment.
Google, whose Gmail is the world's largest email service, said Tuesday that it hadn't received a similar spying request from the U.S. government. If it had, Google said, its response would be: "No way."
Microsoft, whose email service also is larger than Yahoo's, said it has "never engaged in the secret scanning of email traffic." Twitter, which doesn't provide email service but does allow users to exchange direct messages, likewise said it has never received such a request and would challenge it in court if it did.
Yahoo's Latest Email Problem
The report will likely test the bounds of Yahoo users' already stressed loyalty.
Yahoo, late last month, disclosed that hackers had broken into at least 500 million user accounts to steal email addresses, birthdates, phone numbers and passwords. That theft, the biggest breach ever at an email provider, occurred in 2014 when Yahoo's security was run by Alex Stamos, who now holds a similar job at Facebook.
The cooperation with the government's spying on emails created a rift between Stamos and Yahoo CEO Marissa Mayer, prompting Stamos to leave in June 2015, according to Reuters.
Questions over Yahoo's stewardship of user email could threaten the company's deal to sell its online operations to Verizon Communications for $4.8 billion.
Verizon could renegotiate the terms or call off the deal entirely if the fallout from the massive hacking attack drives Yahoo users away from its email and other services, such as news, finance and sports.
After news of the breach broke last month, Verizon said it intended to act in its best interests without elaborating. Verizon had no comment on the Reuters report.