Tony Blair has given his backing to David Cameron's warning of a "generational" struggle against terrorism, in the wake of the Algerian hostage crisis.

The former prime minister who led Britain into Afghanistan and Iraq said Britain could not allow north Africa to become a "safe haven for violent extremists".

Writing in The Sun on Wednesday, Blair said the UK "cannot afford to allow large areas of our world, no matter how remote or inhospitable they might seem, to fall under the control of those determined to export their brand of violence and hatred".

"David Cameron is right to warn that this is a battle for our values and way of life which will take years, even decades," he said.

"We cannot pull everyone back within our borders, nor guarantee their safety if we did. For we also found out on 9/11 what can happen if we allow a country, even a nation as far away as Afghanistan, to become a safe haven for violent extremists."

Blair also said it would be "totally wrong" to blame French military intervention in Mali for the attack on the Algerian gas field that led to the deaths of at least 57 hostages.

"I also believe that France was entirely right to come to the aid of Mali. President Hollande was courageous to sanction it," Blair said.

Last week Cameron made one of his most pro-interventionist speeches to date - telling MPs he would pursue terrorists with an "an iron resolve".

In opposition Cameron had explicitly distanced himself from Blair's liberal-interventionist approach to foreign policy that saw Britain sign up to the invasion of Iraq.

However professor Michael Clarke, the director-general of the think-tank RUSI has warned that it would be wrong for Cameron to regard the threat in north Africa as a continuation of the same jihadist challenge that produced the 9/11 attacks and much else thereafter.

Writing on The Huffington Post UK Clarke said: "The danger of the prime minister's rhetoric and what might follow from it, is that it can serve to unite forces that might otherwise be fractious and ineffective.

"The most obvious strategic mistake would be to unite forces which will otherwise become more disparate in the natural course of events."