Britain's spy agency GCHQ intercepted millions of people's webcam chats and stored still images of them, including sexually explicit ones, the Guardian newspaper reported on Thursday, according to The Guardian.

GCHQ files dating between 2008 and 2010 provided to the newspaper by the former U.S. National Security Agency contractor Edward Snowden revealed that the surveillance program, codenamed Optic Nerve, saved one image every five minutes from randomly selected Yahoo Inc webcam chats and stored them on agency databases, The Guardian reported.

Optic Nerve, which began as a prototype in 2008 and was still active in 2012, was intended to test automated facial recognition, monitor GCHQ's targets and uncover new ones, the Guardian said, according to The Guardian.

In response to the reports, GCHQ said there are no restrictions under British law preventing images of U.S. citizens being accessed by British intelligence, The Guardian reported.

GCHQ collected images from the webcam chats of more than 1.8 million users globally in a six-month period in 2008 alone, according to The Guardian.

"It is a long-standing policy that we do not comment on intelligence matters," a GCHQ representative said on Thursday, The Guardian reported.

The report also shows the webcam information was fed into the NSA's search tool and all of the policy documents were available to NSA analysts, The Guardian reported. It was not clear, however, whether the NSA had access to the actual database of Yahoo webcam images.

Yahoo said it had no knowledge of the interceptions, according to The Guardian.

For decades, the NSA and GCHQ have shared intelligence under an arrangement known as the UKUSA agreement, The Guardian reported. They also collaborate with eavesdropping agencies in Canada, Australia and New Zealand in what is known as the "Five Eyes" alliance.

Under Optic Nerve, GCHQ tried to limit its staff's ability to see the webcam images, but they could still see the images of people with similar usernames to intelligence targets, The Guardian reported.

GCHQ also implemented restrictions on the collection of sexually explicit images, but its software was not always able to distinguish between these and other images, according to The Guardian.

"Discussing efforts to make the interface "safer to use", it (GCHQ) noted that current "naïve" pornography detectors assessed the amount of flesh in any given shot, and so attracted lots of false positives by incorrectly tagging shots of people's faces as pornography," The Guardian reported.