By Sarah Young

LONDON (Reuters) - Prime Minister David Cameron said on Monday Britain's spies acted within the law following revelations the intelligence agencies had received data collected secretly by the United States from the world's biggest internet companies.

British lawmakers have demanded answers from the government after the Guardian newspaper suggested the United States might have handed over phone and internet data about Britons, potentially allowing spies to circumvent current legislation.

The information was gathered under a top secret U.S. program codenamed PRISM which collected emails, internet chat and files directly from the servers of companies such as Google, Facebook, Twitter and Skype.

"I'm satisfied that we have intelligence agencies that do a fantastically important job for this country to keep us safe, and they operate within the law," Cameron told reporters after a speech on Monday.

He said it was vital that the intelligence agencies worked within a proper legal framework but said he was happy that that was the case.

"I am satisfied from the questions I ask and always will continue to ask that they operate in a way that is proper and that is fitting," he said. "They also operate within a framework that they (are) open to proper scrutiny by the intelligence and security committee."

Foreign Secretary William Hague, who is due to address parliament on Monday about the reports, has also said Britain's eavesdropping agency, known as GCHQ, had broken no laws, though he refused to confirm or deny that Britain had received the secretly-collected data.

Lawmakers have asked whether British spies might have circumvented a law that demands senior-level approval for intercepting emails and internet data about people in the United Kingdom, by simply asking for it from the United States.

"One of the big questions that's 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?" Malcolm Rifkind, the chairman of parliament's Intelligence and Security Committee, told BBC Radio 4.

"The law's 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," he said.

"Normally, that means ministerial authority, and that applies equally, whether they're going to do the intercept themselves or whether they're going to ask somebody else to do it on their behalf."

U.S. law puts limits on the government's authority to snoop at home but virtually no restrictions on U.S. spies eavesdropping on the communications of foreigners, including in allied countries, such as Britain, with which Washington shares intelligence.

The Guardian said it had obtained documents which showed GCHQ had generated 197 intelligence reports from PRISM last year. GCHQ, the Government Communications Headquarters, is the responsibility of Foreign Secretary Hague.

"As the minister responsible for GCHQ he does need to seek to give assurances to parliament about the laws and procedures that are in place," Douglas Alexander, foreign affairs spokesman for the opposition Labour party, told the BBC.

"We need clarity in terms of what are the procedures, what are the protocols and what are the laws."

The Guardian reported that GCHQ had been secretly gathering intelligence from PRISM and had had access to the system since at least June 2010.

GCHQ said in an emailed statement to Reuters last week: "Our work is carried out in accordance with a strict legal and policy framework which ensures that our activities are authorized, necessary and proportionate."

(Writing by Guy Faulconbridge and Michael Holden; Editing by Mike Collett-White)