More than three quarters of Germans said they believed their country would soon be hit by a terrorist atrocity, according to the poll published on Friday, showing fears had leapt significantly from a survey published just a fortnight ago.

The horror of the Nice lorry attack in neighbouring France, coupled with the train attack earlier in the week by an axe-wielding asylum seeker apparently spurred into action by Islamic State propaganda, had led to a growing feeling of foreboding in the country.

Heavily armed police forces stand outside the Olympia shopping centre where several people have been killed in a shooting in MunichCredit:
Sebastian Widmann

In a country that hosts both Islamists and far-Right terror groups, violent attacks have always been possible.

Tensions between native and immigrant Germans have been on the rise since Germany accepted nearly one million refugees during last year's migrant crisis, in which Bavaria was on the front line.

While recent atrocities have hit France and Belgium, Germany has many similarities which mean it has been waiting for an attack.

Shashank Joshi, a senior fellow at the Royal United Service Institute, said: “There are any number of reasons Germany might be hit. It’s a big state with huge open borders just like France and Belgium.”

Just like France and Belgium, Germany has had a significant number of its residents join the flow of international jihadists to Iraq and Syria in the past few years. The most recent figures estimate more than 700 men and women from Germany may have gone to join extremist groups such as Islamic State in Iraq and Levant (Isil), with many of them expected to have later returned home.

Last month, the German justice ministry admitted the federal prosecutor was conducting 120 investigations into more than 180 suspects and defendants “in connection with the Syrian civil war for their membership or support of a terrorist organisation”.

The Nato member also played a significant role in military campaigns during the war on terror in the past 15 years, provoking the anger of jihadist groups.

The country still has troops in Afghanistan, having deployed thousands to the country in the past decade. It is also now playing a leading role in training up Kurdish troops to fight Isil in northern Iraq, where German soldiers are training Kurdish Peshmerga militiamen to use anti-tank weapons.

Angela Merkel has allowed hundreds of thousands of refugees and migrants fleeing Syria and Iraq to enter the country in the past asylum the past 18 months, leading to fears that jihadist organisations may have used the influx as a cover to enter.

Mr Joshi said Mrs Merkel’s opponents would be closely scrutinising the attack to see if there was any link to her policy.

He said: “If there’s a refugee connection, it will be big political news for Europe, but it’s quite possible it will have nothing to do with them.”

Germany’s links to Islamist terrorism go back decades, to long before the current crisis with Isil.

A small group of radical Middle Eastern Islamists formed in the 1990s known as the Hamburg cell went on to produce three of the 9/11 hijackers.

More recent terror incidents have included an alleged plot by four suspected Isil members last month to launch suicide bombings in the city of Düsseldorf.

Federal prosecutor’s office said the suspects had planned to deploy two suicide bombers on Heinrich-Heine-Allee street before more attackers killed as many passers-by as possible with guns and explosives.

Intelligence agents last year reportedly foiled a plot to detonate three bombs inside a Hanover football stadium during a friendly international football match.

Last week a young refugee was shot dead on a train after he attacked passengers with an axe.

But for all the fears of Islamist terrorism, the social tensions of the large influx of refugees into the country have also led to a sharp rise in the popularity of extreme and sometimes violent far right groups.