Angela Merkel's open-door policy towards immigrants fleeing Middle East war zones will, in the long run, make Germany safer from terrorist attacks.

By showing compassion to hundreds of thousands of Muslim refugees, the German Chancellor has sent a message to the world that Germany is not at war with Islam.

More importantly, this means that the vast majority of Muslims resident in Germany have every reason to cooperate with the security services in the fight against terrorism.

This is not something that can be said of the marginalised and radicalised Muslim communities of the run-down suburbs of Brussels or Paris which breed and harbour terrorist networks.

Timeline: Germany rocked by week of deadly violence

The key to beating terrorism is winning the hearts and minds of Muslims living in the communities that are vulnerable to radicalisation by hate preachers and terror groups like Islamic State and al-Qaeda. So while Merkel's critics have been quick to blame her for the recent attacks in Bavaria it is possible that her actions have already saved the country from the kind of organised mass-murder bomb and gun attacks which have taken place in France and Belgium. These attacks have sprung from the suburbs of Paris and Brussels which have become incubators of terrorism. The hatred and resentment which has taken hold there may take generations to overcome.

Certainly the Paris banlieues and the Molenbeek suburb of Brussels are populated by Muslims who no longer feel they have a stake in mainstream society. Many of the young Muslims brought up there have already headed out to Syria and Iraq to live and fight in the caliphate. Those who have chosen to stay continue to nurse grievances against a state which sends more and more police into their communities to knock down doors and make arrests.

Loading....

François Hollande has frequently announced that he is at war with Isis. For many Muslims who feel they have become criminalised by their religion the French President might as well be declaring war on them.

The truth is that foreign policy does play a vital role in the radicalisation and incentivisation of terrorists. It is a lesson that France benefitted from during the Iraq war when its government vehemently opposed that conflict. During this period France was free from terrorist attacks, whereas Britain who instigated and waged war against Saddam Hussein, suffered the London bomb attacks of 7/7. Spain too, a high profile supporter of the war, faced the Madrid train bombings in 2004.

Refugees settle in Germany Show all 12 1 /12 Refugees settle in Germany Refugees settle in Germany Germany Mohamed Zayat, a refugee from Syria, plays with his daughter Ranim, who is nearly 3, in the one room they and Mohamed's wife Laloosh call home at an asylum-seekers' shelter in Vossberg village on October 9, 2015 in Letschin, Germany. The Zayats arrived approximately two months ago after trekking through Turkey, Greece and the Balkans and are now waiting for local authorities to process their asylum application, after which they will be allowed to live independently and settle elsewhere in Germany. Approximately 60 asylum-seekers, mostly from Syria, Chechnya and Somalia, live at the Vossberg shelter, which is run by the Arbeiter-Samariter Bund (ASB) charity 2015 Getty Images Refugees settle in Germany Germany A refugee child Amnat Musayeva points to a star with her photo and name that decorates the door to her classroom as teacher Martina Fischer looks on at the local kindergarten Amnat and her siblings attend on October 9, 2015 in Letschin, Germany. The children live with their family at an asylum-seekers' shelter in nearby Vossberg village and are waiting for local authorities to process their asylum applications. Approximately 60 asylum-seekers, mostly from Syria, Chechnya and Somalia, live at the Vossberg shelter, which is run by the Arbeiter-Samariter Bund (ASB) charity Getty Images Refugees settle in Germany Germany Kurdish Syrian asylum-applicant Mohamed Ali Hussein (R), 19, and fellow applicant Autur, from Latvia, load benches onto a truckbed while performing community service, for which they receive a small allowance, in Wilhelmsaue village on October 9, 2015 near Letschin, Germany. Mohamed and Autur live at an asylum-applicants' shelter in nearby Vossberg village. Approximately 60 asylum-seekers, mostly from Syria, Chechnya and Somalia, live at the Vossberg shelter, which is run by the Arbeiter-Samariter Bund (ASB) charity Getty Images Refugees settle in Germany Germany Mohamed Ali Hussein ((L), 19, and his cousin Sinjar Hussein, 34, sweep leaves at a cemetery in Gieshof village, for which they receive a small allowance, near Letschin Getty Images Refugees settle in Germany Germany Mohamed Zayat, a refugee from Syria, looks among donated clothing in the basement of the asylum-seekers' shelter that is home to Mohamed, his wife Laloosh and their daughter Ranim as residents' laundry dries behind in Vossberg village on October 9, 2015 in Letschin, Germany. The Zayats arrived approximately two months ago after trekking through Turkey, Greece and the Balkans and are now waiting for local authorities to process their asylum application, after which they will be allowed to live independently and settle elsewhere in Germany Getty Images Refugees settle in Germany Germany Asya Sugaipova (L), Mohza Mukayeva and Khadra Zhukova prepare food in the communal kitchen at the asylum-seekers' shelter that is their home in Vossberg village in Letschin Getty Images Refugees settle in Germany Germany Efrah Abdullahi Ahmed looks down from the communal kitchen window at her daughter Sumaya, 10, who had just returned from school, at the asylum-seekers' shelter that is their home in Vossberg Getty Images Refugees settle in Germany Germany Asylum-applicants, including Syrians Mohamed Ali Hussein (C-R, in black jacket) and Fadi Almasalmeh (C), return from grocery shopping with other refugees to the asylum-applicants' shelter that is their home in Vossberg village in Letschin Getty Images Refugees settle in Germany Germany Mohamed Zayat (2nd from L), a refugee from Syria, smokes a cigarette after shopping for groceries with his daughter Ranim, who is nearly 3, and fellow-Syrian refugees Mohamed Ali Hussein (C) and Fadi Almasalmeh (L) at a local supermarket on October 9, 2015 in Letschin, Germany. All of them live at an asylum-seekers' shelter in nearby Vossberg village and are waiting for local authorities to process their asylum applications, after which they will be allowed to live independently and settle elsewhere in Germany 2015 Getty Images Refugees settle in Germany Germany Kurdish Syrian refugees Leila, 9, carries her sister Avin, 1, in the backyard at the asylum-seekers' shelter that is home to them and their family in Vossberg village in Letschin Getty Images Refugees settle in Germany Germany Somali refugees and husband and wife Said Ahmed Gure (R) and Ayaan Gure pose with their infant son Muzammili, who was born in Germany, in the room they share at an asylum-seekers' shelter in Vossberg village on October 9, 2015 in Letschin, Germany. Approximately 60 asylum-seekers, mostly from Syria, Chechnya and Somalia, live at the Vossberg shelter, which is run by the Arbeiter-Samariter Bund (ASB) charity, and are waiting for authorities to process their application for asylum 2015 Getty Images Refugees settle in Germany Germany German Chancellor Angela Merkel pauses for a selfie with a refugee after she visited the AWO Refugium Askanierring shelter for refugees in Berlin Getty Images

Now France and Belgium are being targeted by sophisticated terror operations planned from Syria and Iraq as well as home-grown “lone wolf” jihadis who have been radicalised on the internet. The untrusted French and Belgian security services have been unable to gather vital intelligence from these neglected parts of their cities. This means the intelligence failures that led up to attacks on Charlie Hebdo, the Bataclan, the Brussels transport system and Nice are likely to be repeated.

Critics of Mrs Merkel argue that by announcing an immigration free-for-all she has endangered the lives of ordinary Germans. But the recent flow of refugees from war zones into Europe has not increased the risk of terrorism.

This is supported by the fact that all three asylum seekers who carried out attacks in Germany this week had entered the country long before Mrs Merkel announced her immigration policy last year.