The extremist threat behind the Tunisia beach atrocity can be defeated in the long-term with a "full spectrum response" focused on radicalisation in the UK as well as overseas, David Cameron said.

The Prime Minister said the "existential threat" posed by the emergence of the so-called Islamic State in Iraq and Syria was "the struggle of our generation and we have to fight it with everything we can".

He defended Britain's role in the limited military action being taken against it, rejecting claims airstrikes made UK citizens more of a target and playing down calls for an escalation of the fight.

But he also insisted the Government was right to take a hard line against domestic groups that supported an "extremist narrative" - including the creation of an Islamic caliphate and the subjugation of women - even if they opposed terrorism.

Writing in the Daily Telegraph, Mr Cameron said the slaughter by a gunman of 38 people - among them at least 30 British holidaymakers - in the resort of Sousse on Friday "demonstrates the level of evil we are dealing with".

"But we will not be cowed," he added.

"To our shock and grief we must add another word: resolve. Unshakeable resolve. We will stand up for our way of life. So ours must be a full-spectrum response - a response at home and abroad; in the immediate aftermath and far into the future."

Interviewed by BBC Radio 4's Today, the PM said: "It is an existential threat because what has happened here is the perversion of a great religion and the creation of this poisonous death cult which is seducing too many young minds in Europe, America, the Middle East and elsewhere.

"This is, I think going to be the struggle of our generation and we have to fight it with everything we can.

"The way to combat this threat and to beat it - and I believe we will beat it because our system of values of democracy and freedom and fairness and tolerance is so much greater than their system of values - is you have to have what I call a "full spectrum" response: yes of course you have to crush Isil in Iraq and Syria and Britain is playing a very large part in that ... but squeezing it at source and destroying it at source is not enough; we have to deal with this appalling radical narrative that is taking over the minds of so many people in our own country."

"It is a battle we have to fight on every front."

Mr Cameron - who renewed an appeal for the group behind many recent attacks to be referred to only by the abbreviation Isil or "so called Islamic State" to counter any suggestion of legitimacy - said it was right for UK forces to be involved in Iraq.

"They have declared war on us and they are attacking our people at home and overseas whether we like it or not. Frankly I don't think you can hide from this threat or think that if you step back somehow you become less of a target.

"We have to stand united with others who share our values," he added - pointing out that attacks had taken place in many other countries in recent months and years.

"The 'put your head in the sand, try and cut yourself off from the world, think that it's impossible to deal with these problems' approach is wrong.

"We can - if we show unity, purpose, resolve and determination, work with our allies, use the incredible assets that we have, assert our system of values and democracy and the rest of it - we can beat these people."

Former head of the army Lord Dannatt is among senior figures calling for special forces to be sent in on the ground to help destabilise Isil's hold on swathes of territory amid concerns the allied action is failing.

Mr Cameron said airstrikes had already won back "a lot of territory" and the "right strategy" was to build up local armies and - vitally - governments that could represent everyone in the countries involved.

"It is much easier to just invade a country, I absolutely accept that - and that has consequences," he said in an apparent swipe at the 2003 US-led military action that toppled Saddam Hussein in Iraq.

"The Secretary General of the UN put it best: a missile can kill a terrorist but it is good government that kills terrorism.

"Whether it is Iraq, whether it is Syria, whether it is Libya, the same thing is required which is governments which can represent all of their people."

Mr Cameron dismissed criticism from Tory former minister Baroness Warsi that his appeal to Muslims not to "quietly condone" terrorist groups meant he had "lost sections of the Muslim community".

"I have an honest disagreement with Sayeeda who I have debated this with many times.

"My point is that we should engage with imams, with Muslim communities, with Muslim organisations but we should have some basic rules in terms of our engagement and if organisations back extremist preachers or believe that it's all right to be a suicide bomber in Israel, it's just not all right to commit terrorist acts elsewhere then I think we have a serious problem.

"The way we engage should be engaging with organisations that want to build an integrated, democratic, successful, multi-racial Britain. That's what I believe in and that's what most Muslims believe in, the vast majority.

"Having a dialogue with people that don't take that view doesn't help."

Asked if British Muslims had not been tough enough in condemning such acts of terrorism, Mr Cameron said: "No, I don't believe that is the case ... the point I am making is there are some organisations and some people who buy not the terrorism, but they buy a lot of the extremist narrative. To those people we have got to say that is not an acceptable view.

"We are not going to engage with people who believe there ought to be a caliphate and women should be subjugated.

"My point is some organisations set themselves up as representative of Muslim communities when actually they are not. Do not treat them as spokespeople for all of the community."