A Syrian suicide bomber who killed himself and injured 12 others outside a music festival in the German town of Ansbach was supposed to have been deported to Bulgaria before carrying out his attack, German officials have revealed.

German daily Deutsche Welle reported that the 27-year-old refugee was denied his asylum request in Germany and had been slated for deportation to Bulgaria.

A spokesman for Germany's interior ministry reported on 25 July it was not clear why the deportation of the man had not gone ahead. "I can't say at this moment why the deportation didn't take place," Tobias Plate was quoted as saying.

The attacker was living in an apartment in Ansbach at the time of the attack, and could not be returned to Syria because of the dangerous conditions there.

German police released the age and nationality of the attacker, but have so far withheld his name. The man was reported to have attempted to kill himself two times while in psychiatric care since he arrived in Germany two years ago.

As authorities said 12 people had been wounded in the attack in the small Bavarian town of Ansbach, whether the attacks was planned for either personal or political reasons remains unclear. Reuters cited unnamed US intelligence officials as saying investigators would now focus on the 27-year-old's movements before he left Syria and why he had been denied asylum.

Bavaria's interior minister told reporters it was unclear whether the attacker planned just to kill himself or whether he hoped to carry out an Islamic State-style attack. Joachim Herrmann said he may have planned "take others with him into death".

The Syrian national's backpack was filled with explosives and metal shrapnel that would have had the power to kill a number of people. However, he was denied access to a packed music festival when he failed to produce a ticket and then detonated his device outside the nearby Eugens Weinstube restaurant.

A total of 2,000 festival goers had to be evacuated following the attack. Resident Thomas Debinski was quoted as saying people panicked when they heard the explosion after a week of violence in Bavaria that has witnessed three attacks in seven days.

"Suddenly you heard a loud, a really loud bang, it was like an exploding sound, definitely an explosion," Debinski was quoted as saying. He added it soon became clear that someone had set off a bomb in a rucksack.

The explosion follows a recent mass shooting, carried out by an 18-year-old gunman on Friday (22 July), near the Olympia shopping centre in Munich. David Ali Sonboly's deadly rampage killed nine people.

Earlier on Sunday (24 July), a Syrian asylum-seeker killed one woman and left two others injured after carrying out a machete attack in the town of Reutlingen, near Stuttgart. Police said the attacker had been taken into custody.