Intelligence agencies can legally ask for customer data from internet companies but this kind of surveillance has been modestly scaled back after the revelations of snooping by formerNSA contractor Edward Snowden.
Yahoo has been among companies which have in the past challenged surveillance orders in the Foreign Intelligence Surveillance Court (FISA) but the sources said they did not challenge this one because they thought they would lose.
In a statement to Reuters, Yahoo Inc said: “Yahoo is a law abiding company, and complies with the laws of the United States.”
Yahoo’s security has been in the headlines after it emerged in September that a hacker got access to 500m customer accounts in 2014.
Apple successfully argued not to create a programme to break into an encrypted iPhone used in the 2015 San Bernardino massacre.