Image caption The government had tried to "explain how damaging some of these things can be", the PM told MPs

It would be "very difficult" not to take action against newspapers that continue to publish "damaging" security leaks, David Cameron has said.

In the Commons, the prime minister said it was "better to appeal to newspapers' sense of social responsibility".

But the government could take out injunctions against further publication of intelligence data, he suggested.

The Guardian has insisted that its coverage of intelligence leaks prompted a necessary and overdue debate.

The British newspaper has been the primary UK outlet for stories based on data leaked by whistleblower and ex-US security analyst Edward Snowden.

Conservative MP Julian Smith asked Mr Cameron: "Is it not time that any newspaper that may have crossed the line on national security comes forward and voluntarily works with the government to mitigate further risks to our citizens?"

'Deep concerns'

Guardian editor Alan Rusbridger has said the paper was right to report on the leaked files.

But the PM argued: "We have a free press, it's very important the press feels it is not pre-censored from what it writes and all the rest of it.

If they don't demonstrate some social responsibility it would be very difficult for government to stand back and not to act David Cameron

"The approach we have taken is to try to talk to the press and explain how damaging some of these things can be."

He referred to the Guardian's decision to accede to a request from the government to destroy some of the leaked files. The newspaper maintained at the time that it had other copies.

The PM added: "But they've now gone on and printed further material which is damaging.

"I don't want to have to use injunctions or D notices [issued when the UK government wants to prevent the media from reporting something for national security reasons] or the other tougher measures.

"I think it's much better to appeal to newspapers' sense of social responsibility.

"But if they don't demonstrate some social responsibility it would be very difficult for government to stand back and not to act."

Mr Cameron was taking questions after delivering a Commons statement on the recent EU summit.

During the exchanges, Labour leader Ed Miliband urged the government to ensure "proper oversight" of the security services, following claims the US listened to phone calls by German Chancellor Angela Merkel.

The Labour leader told MPs there were "deep concerns" over the allegations.

But Mr Cameron said the UK intelligence services worked "under the law" and had foiled dozens of terrorist threats in recent years.

German media say the US has been tapping Ms Merkel's phone since 2002.

The White House insists Mr Cameron's communications have not been monitored.

Allegations that US agencies engaged in widespread tapping of phone calls by prominent European politicians dominated the two-day European Council summit in Brussels.

Mr Cameron signed up to a statement from all 28 EU leaders calling for the rebuilding of trust with the United States.

'Secret mourning'

He said the UK and US had "a relationship based on trust".

He added: "In terms of our own intelligence services... we don't comment on their work, but they have parliamentary scrutiny."

Mr Cameron also said: "Our agencies work under the law."

He added: "Of course, as technology develops, the threats we face evolve... But we have every reason to be proud of our intelligence agencies and the work they do."

The prime minister told MPs that 330 people had been convicted of terror offences in British courts since the 11 September 2001 attacks on the US.

He said: "Our intelligence officers serve our country without any public recognition. Some have given their lives in this service and yet their names are not known. Their loved ones must mourn in secret.

"We owe them and every intelligence officer in our country an enormous debt of gratitude. They are silent heroes and heroines keeping our country safe. They deserve our support."

Mr Miliband joined Mr Cameron in endorsing the work of the intelligence services.

He said: "It is vital. It keeps us safe, and, as you said, by its very nature it goes unrecognised."

But he added: "I also support the summit statement on this issue - we can all understand the deep concerns recent reports have caused in some European countries, especially Germany.

"So as well as providing that support for intelligence services, it is right every country ensures proper oversight of those activities."

US President Barack Obama is reported to have told Mrs Merkel that he knew nothing of the operation when the two leaders spoke.

Germany is sending intelligence chiefs to Washington in the coming week to "push forward" an investigation into the spying allegations.