Speaking at an event in Essex, the prime minister sidestepped whether he had known about GCHQ access to Prism by saying he would not give a running commentary on the actions of the intelligence services.

He said he had discussed the issue with William Hague in advance of the foreign secretary's statement to MPs on Monday afternoon.

Describing himself as the first minister for the intelligence services, he said the Woolwich attack on Drummer Lee Rigby had shown the UK lived in a dangerous world.

Cameron said: "Let us be clear. We cannot give a running commentary on the intelligence services. There are things that William Hague will be able to say and questions he will be able to answer. I am satisfied that the intelligence services, who do a fantastically important job to keep us safe, operate within the law and within a legal framework and they also operate within a proper framework of scrutiny by the intelligence and security committee.

"We do live in a dangerous world and live in a world of terror and terrorism. I do think it is right we have well-funded and well-organised intelligence services to keep us safe."

Downing Street also said that GCHQ operated within the law. The prime minister's spokesman said: "One of the things the foreign secretary said yesterday is: 'If information arrives in the UK, it is governed by our laws.'

The prime minister believes, and very much agrees with the point that William Hague was making yesterday, which is that there is very strong ministerial oversight [of Britain's intelligence agencies]. The prime minister thinks there is a very strong legal framework, there is very strong ministerial oversight, the foreign secretary noted the assessment by the commissioners, who are also part of the oversight process, with reference to the highest standards of integrity and legal compliance by GCHQ."

Earlier, the former foreign secretary Sir Malcolm Rifkind said Britain's electronic eavesdropping centre would have been in breach of the law if it asked for data about UK citizens without the approval of ministers.

As the shadow foreign secretary, Douglas Alexander, said he would challenge Hague to explain the legal basis on which GCHQ operated, Rifkind indicated that he would ask the US National Security Agency (NSA) about the matter this week.

The documents suggested that GCHQ had generated 197 intelligence reports from the NSA-run Prism last year. The system would appear to allow GCHQ to bypass formal legal processes to access personal material, such as emails and photographs, from the world's biggest internet companies.

Rifkind, who was responsible for overseeing GCHQ as foreign secretary between 1995 and 1997, said Snowden had broken the law. He told the Today programme on BBC Radio 4: "If you work for an intelligence agency you are required, as are the rest of us, to obey the law of the land. Revealing classified information is normally a criminal offence and leads to various consequences."

But he indicated that GCHQ might have also fallen foul of the law if it requested information from the NSA on British citizens. "One of the big questions that is being asked is if British intelligence agencies want to seek to know the content of emails can they get round the normal law in the UK by simply asking an American agency to provide that information?" he said.

"The law is actually quite clear. If the British intelligence agencies are seeking to know the content of emails about people living in the UK then they actually have to get lawful authority. Normally that means ministerial authority. That applies equally whether they are going to do the intercept themselves or whether they are going to ask somebody else to do it on their behalf."

Rifkind, who will meet the NSA and CIA in Washington this week, defended the work of intelligence agencies on both sides of the Atlantic. "The job of the UK is to ensure its own citizens are protected from terrorist attacks. In order to achieve that we work closely with American intelligence agencies, they work very closely with us," he said.

"We share information where in any particular circumstance we believe there is evidence that, if it is not used, could result in a terrorist attack and innocent people being killed. That goes on for years. It is what parliament and the public expect."

Alexander also defended the "vital work" of intelligence agencies in helping to protect people against terrorist attacks. But the shadow foreign secretary said he would ask Hague to clarify the legal basis on which GCHQ co-operates with the NSA.

The former Foreign Office minister told the Today programme: "Of course there are long standing relationships between the NSA and GCHQ and we need those to be in place. They have been in place for many, many years. But what we need clarity from the foreign secretary today is the legal framework governing UK access to intercepts secured by the NSA.

"That seems to be one of the central allegations in the coverage in the Guardian. So we need clarity in terms of what are the procedures, what are the protocols and what are the laws that operate."

Hague said on Sunday that it was nonsense to suggest GCHQ had circumvented the law. He told The Andrew Marr Show on BBC1: "The idea that in GCHQ people are sitting working out how to circumvent a UK law with another agency in another country is fanciful. It is nonsense."