British spy agency GCHQ intercepted webcam images from millions of Yahoo users around the world, according to a report in the Guardian.
Yahoo denied prior knowledge of the alleged programme, describing it as a "completely unacceptable" privacy violation. According to leaked documents, sexually explicit images were among those gathered - although not intentionally.
In a statement GCHQ has said all of its actions are in accordance with the law.
The operation, which was called Optic Nerve and was aided by the US National Security Agency, is alleged to have stored images between 2008 and 2010. In one six-month period in 2008, images from 1.8m users were gathered.
The report originated from documents leaked by whistleblower Edward Snowden. It suggested that sexually explicit content would be captured by the system.
"Unfortunately … it would appear that a surprising number of people use webcam conversations to show intimate parts of their body to the other person," it read.