Ansbach (Germany) (AFP) - Germany warned Monday of a potential backlash against migrants after a Syrian asylum seeker blew himself up outside a music festival, capping a week of attacks that has shaken the country.

The 27-year-old attacker wounded more than a dozen people in the southern city of Ansbach Sunday night and had spent time in a psychiatric facility, regional authorities said.

Berlin said there was as yet "no credible evidence" of a link to Islamic extremism.

Europe's economic powerhouse was already reeling after nine people died in a shopping centre shooting rampage in Munich on Friday and four people were wounded in an axe attack on a train in Wuerzburg on July 18.

All three assaults were in Bavaria which has been a gateway for tens of thousands of refugees under Chancellor Angela Merkel's liberal asylum policy.

Merkel's deputy spokeswoman Ulrike Demmer expressed the government's "shock" after the rash of attacks but also warned against branding all refugees a security threat.

"Most of the terrorists who carried out attacks in recent months in Europe were not refugees," she told reporters.

"The terrorism threat (among refugees) is not larger or smaller than in the population at large."

Interior Minister Thomas de Maiziere also warned against placing refugees "under general suspicion", despite "individual cases that are under investigation".

Police said the man intended to target the open-air festival but was turned away as he did not have a ticket, and detonated the device outside a nearby cafe.

"If he had made it inside, there would certainly have been more victims," a police spokesman said.

The explosion went off in the centre of the city of Ansbach, not far from where more than 2,500 people had gathered for the concert, at around 10 pm (2000 GMT).

The perpetrator was killed in the blast and 15 people were wounded, four of them seriously.

- Attacker known to police -

Ansbach deputy police chief Roman Fertinger said there were "indications" pieces of metal had been added to the explosive device.

Story continues

The attacker, who came to Germany two years ago but had his asylum claim rejected after a year, had tried to kill himself twice in the past and had spent time in a psychiatric clinic, authorities said.

He was facing imminent deportation to Bulgaria, where he was first registered within the European Union as an asylum seeker, a German interior ministry spokesman said.

The assailant, who lived in Ansbach, was already known to police, having been linked to a drug-related offence.

However a social worker who knew him, Reinhold Eschenbacher, described him as "friendly, inconspicuous and nice" when he came to his office pick up his welfare benefits, DPA news agency reported.

Stephan Mayer, a deputy from Merkel's conservative bloc, insisted that it was "completely wrong" to blame the government's refugee policy for the recent rash of attacks.

But Mayer told the BBC that the 1.1 million migrants and refugees Germany let in last year represented a "big challenge" for law enforcement, even as the influx has dwindled in recent months.

"We were not able to register and control all the migrants that crossed the German border," said Mayer.

Europe has been on edge for months after a string of deadly attacks claimed by the Islamic State jihadist group, including bombings in Brussels and carnage at Bastille Day celebrations in the southern French city of Nice.

- Obsessed with mass murder -

Meanwhile police released more details on Munich mall attacker David Ali Sonboly, saying the 18-year-old was depressed and had spent two months in a psychiatric unit last year.

The teen, who had German and Iranian nationality, was obsessed with mass killings and spent a year preparing for the shooting spree, police said.

At least 35 people were also wounded during Sonboly's attack, which began at a McDonald's franchise and ended with him turning his 9mm Glock pistol on himself.

Investigators have ruled out any link with IS jihadists, although he appeared to have planned the assault with chilling precision for a year.

Police have also arrested a 16-year-old Afghan friend in connection with the shooting.

The two were in psychiatric treatment together last year and allegedly met at the scene of the attack shortly before it began, prosecutors said Monday.

Hundreds of people, many of them in tears, gathered on Sunday outside the Munich shopping centre where the attack took place to pay tribute to the victims.

Already steeped in grief and shock, Germans were further rattled by news that a Syrian refugee had killed a 45-year-old Polish woman with a large kebab knife at a snack bar in the southwestern city of Reutlingen.

Police, who had initially said the murder weapon was a machete, added that Sunday's incident in which three others were injured was likely a "crime of passion".

Three people were also injured in the attack, which ended when the 21-year-old assailant was deliberately struck by a BMW driver trying to stop the man.