London: 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.

GCHQ files dating between 2008 and 2010 provided to the newspaper by the former US National Security Agency (NSA) contractor Edward Snowden, revealed that the surveillance programme, codenamed Optic Nerve, saved one image every five minutes from randomly selected Yahoo webcam chats and stored them on agency databases.

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.

Under British law, there are no restrictions preventing images of US citizens being accessed by British intelligence, it added.

GCHQ collected images from the webcam chats of over 1.8 million users globally in a six-month period in 2008 alone.

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

In another sign of the widespread information-sharing between U.S. and UK spy agencies which has riled public and politicians on both sides of the Atlantic, the webcam information was fed into the NSA's search tool and all of the policy documents were available to NSA analysts, the paper said.

However it was not clear whether the NSA had access to the actual database of Yahoo webcam images, it added.

Snowden, now in Russia after fleeing the United States, made world headlines last summer when he provided details of NSA surveillance programs to the Guardian and the Washington Post.

For decades, the NSA and GCHQ have worked as close partners, sharing intelligence under an arrangement known as the UKUSA agreement. They also collaborate with eavesdropping agencies in Canada, Australia and New Zealand under an arrangement 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 said.

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.

"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 newspaper said.

The spy agency eventually excluded images in which the software had not detected any faces from search results to prevent staff from accessing explicit images, it added.