A sign in front of the Yahoo! headquarters on May 23, 2014 in Sunnyvale, California.
Justin Sullivan, Getty Images Yahoo built surveillance tools at the behest of the National Security Agency or the FBI to look through all of its users' email accounts, according to a report from Reuters citing anonymous former Yahoo employees.
A classified directive from the US government authorized the process, and Yahoo's compliance with the directive prompted the company's then Chief Information Security Officer Alex Stamos to leave the company in June 2015, Reuters said. Stamos now holds a similar position at Facebook.
Yahoo has previously pushed back on government directives to hand over user data to the government. It fought -- and lost -- a court battle over the law that authorizes the Prism program , which was revealed by Edward Snowden and reportedly sends user information from company servers through a portal to US intelligence workers.
That court battle began before Marissa Mayer became CEO of Yahoo in 2012.
Yahoo did not immediately provide a comment in response to the Reuters report. The company is still recovering from a 2014 data breach, revealed in September, that affected more than 500 million Yahoo users .