Reuters news agency says the firm built special software last year to comply with a classified request.
"Yahoo is a law abiding company, and complies with the laws of the United States," the tech firm said in a statement provided to the BBC.
The allegation comes less than a fortnight after Yahoo said hackers had stolen data about many of its users.
Yahoo is in the process of being taken over by Verizon Communications in a $4.8bn (Â£3.8bn) deal. The telecoms provider declined to comment on the report.
Reuters reports that the scans were requested by either the National Security Agency (NSA) or the FBI, according to three sources - two of whom it says were ex-Yahoo employees.
The news agency says that the software scanned for a string of characters within all incoming emails, but adds that it was unable to determine what information was handed over or if other internet companies had received a similar demand.
Google, however, said it had not been asked to carry out such scans.
"We've never received such a request, but if we did, our response would be simple: 'no way'," said a spokesman.
Microsoft added it had "never engaged in the secret scanning of email traffic".
Facebook said it had "never received a request like the one described in these news reports from any government, and if we did we would fight it."
And Twitter said: "We've never received a request like this, and were we to receive it we'd challenge it in a court."
US law allows the country's intelligence agencies to order the release of customer data that they believe could prevent a terrorist attack, among other reasons.
Companies can challenge such orders behind closed doors in the Foreign Intelligence Surveillance Court.
But Reuters reports that Yahoo decided not to fight the matter because it thought it would lose. It adds that some Yahoo employees were upset by that decision.
The whistleblower Edward Snowden, who previously revealed details about the US's cyber-spying efforts, has tweeted in response to the unverified allegations: "Use @Yahoo? They secretly scanned everything you ever wrote... close your account today."
Yahoo secretly scanned millions of its users' email accounts on behalf of the US government, according to a report.