The suicide attacker who bombed a Bavarian town was on the verge of deportation after having his application for asylum rejected.
The 27-year-old Syrian, named in local reports as Mohammad Daleel, had been handed two deportation notifications before he tried to enter a music festival with a backpack full of explosives.
Although he failed to gain entry to the event, in Ansbach, southern Germany, his blast left 15 people injured, four seriously. Daleel died in the attack.
He had been living in the area since July 2, staying at an asylum shelter in the town's suburbs.
He was known to the authorities for drug offences and had received psychiatric care, including for two attempts on his own life.
The bomber was told on July 13 he was to be deported to Bulgaria, which was where he submitted his first asylum request.
Bavarian interior minister Joachim Herrmann said Daleel had been allowed to remain in Germany after his asylum application was rejected due to the Syrian civil war.
He had received his first deportation notice in December 2014, but, given that asylum seekers are regularly deported to the country where they first applied for asylum if official procedures are not observed, it is unclear why he was not made to leave at the time.
Mobile phone footage found at Daleel's address showed him swearing allegiance to Islamic State, which later claimed responsibility for his attack.
Bomb-making materials and violent videos were also found.