General Sir David Richards said the national security of Britain was still under threat from extreme elements of Islamism, but the key point was how that was dealt with.
Al-Qaida was an "unacceptable manifestation" but people should always be allowed to have the "milder forms" of Islam underpinning their lives, said Gen Richards.
He also underlined Britain's aim to end its combat role in Afghanistan by 2014-15 but highlighted hurdles still to be overcome in relation to governance and development in the country.
After it was put to him on the BBC's Andrew Marr Show that "you can't defeat the Taliban or al-Qaida militarily", he said: "You can't, and we have all said this... the trick is the balance of things that you are doing.
"And I say that the military are just about there, but the biggest problem has been ensuring that the governance and all the development side can keep up with it within a timeframe.
"These things take generations sometimes within a timeframe that is acceptable to domestic public and political opinion.
He said: "There is a difference between Islamism in its most extreme forms – al-Qaida – and an idea, and I don't think you can defeat an idea.
It is something that we need to battle back against as necessary. But in its milder forms, why shouldn't they be allowed to have that sort of philosophy underpinning their lives?"
"I think it can be (a threat); it is how it manifests itself that is the key and can we contain that manifestation. Quite clearly al-Qaida is an unacceptable manifestation of it.
In his interview with the Sunday Telegraph, Gen Richards said: "In conventional war, defeat and victory is very clear-cut and is symbolised by troops marching into another nation's capital.
"First of all, you have to ask: do we need to defeat it (Islamist militancy) in the sense of a clear-cut victory? I would argue that it is unnecessary and would never be achieved.
"But we can contain it to the point that our lives and our children's lives are led securely? I think we can.
The general said of the men and women fighting in Afghanistan: "I think there are direct parallels to be made with the bravery of those who risked, and who gave, their lives in the fight against fascism in the Second World War.
He also said the British military and the Government had been "guilty of not fully understanding what was at stake" in Afghanistan and admitted that the Afghan people were beginning to "tire" of Nato's inability to deliver on its promises.
But he said the sacrifice being made by British troops in Afghanistan, where 343 soldiers have been killed since 2001, "has been worth it".
"If I thought for one minute that the majority of the Afghan people didn't want us any more – then I and everyone else would say that it's time to go, we've failed.
"But there is no indication of that."He also said that war widows and injured soldiers must be protected against the "worst excesses" of the coalition Government's cuts to pensions.
He said he was "concerned" at proposals which will leave widows and the injured losing hundreds of thousands of pounds.
He said while he thought the change was a "done deal", he was working on making sure the "worst excesses are properly catered for".
BRITAIN 'LESS AT RISK FROM ATTACKS'
BRITAIN is considered at lower risk from attacks by terrorists than France or the United States, according to a new worldwide study.
Somalia overtook Iraq, Afghanistan and Pakistan to become the country most at risk, moving from four to one in this year's Terrorism Risk Index (TRI), developed by the global risks advisory firm Maplecroft.
The UK was placed at 47, at lesser risk than the US at 33 and France at 44.
All remained in the "medium risk" category, while Canada (67) and Germany (70) were rated as "low risk".
Data from the period June 2009 to June 2010 was used to assess the frequency of terrorist incidents and the intensity of attacks in 196 countries, including the number of victims per attack and the chances of mass casualties occurring.
The index also included a historical component assessing the number of attacks between 2007 and 2009 and looking at whether a country was at risk from a long-standing militant group operating there.