Afghans make up a large proportion of refugees living in Germany, second only to Syrians in their number; Germany has one of the largest Afghan communities in Europe. It has struggled to cope with 2015's influx of refugees, leading the German government to offer Afghans cash to return home, and launch a campaign in Afghanistan calling on nationals to think carefully before making the trip to Europe.
The Würzburg attack has reignited the debate whether Germany's open policy towards refugees has put the country's security at risk by allowing extremists into the country, and also whether there has been a failure in integration policy - the train attacker had lived in Germany for over a year.
Here are some answers to a few of the questions you might have following the attack.
How widespread is Isis in Afghanistan?
The terror group has only had a presence in Afghanistan since early 2015, and bloody clashes with the Taliban have prevented it from growing much. Its fighters - thought to number around 2,500 - are active in just two of the 34 Afghan provinces. Weekly drone strikes by the US have been targeting its bases.
Why are young Afghans fleeing their country?
Afghanistan is one of the poorest countries in the world, with an unemployment rate of 40 percent. At the same time, security issues are growing. Since Nato’s withdrawal in December 2014, the Taliban has felt emboldened, and 31 out of 34 provinces were affected by violence in 2015, according to UN figures. Young, educated people are the most likely to leave the country.
Are there many extremists among the Afghan refugees?
This is difficult to answer. Many young refugees belong to Afghanistan's middle class, and have high school or university level education. The vast majority seem to be seeking a new life in Europe in order to build a higher standard of life for themselves - not to carry out attacks.
However, the research institute Afghanistan Analysts Network believes that radicalization does take place in Afghan universities, so it's not impossible that those fleeing the country have had contact with extremists.
Are fewer Afghans arriving now that the Balkan route has been closed?
This seems to be the case, however the arrivals haven't completely stopped. One people-smuggler in Kabul told DPA that last year he had helped 25 to 30 "clients" escape the country each day, but since the closure of the Balkan route that figure had dropped to ten or 12.
What was the reaction to Monday's attack in Afghanistan?
The events in Würzburg were widely reported in Afghan media on Tuesday, and in Kabul in particular it touched a raw nerve. Many people living in the capital have friends and relatives among the thousands who have fled to Germany. They hope that the attacker will be judged as an individual, and that they won't be blamed for his actions.
"It must have been a 'psycho'," Taufik Jakin, an economics student said, according to DPA. But Jakin added: "I've heard from my friends in Germany that Afghan refugees have lots of problems there."
He said it was important to determine what had led the 17-year-old to carry out the attack.