A 27-year-old Syrian man died when a bomb he was carrying in a rucksack went off outside a music festival in Germany and wounded 12 people, an official said.

A spokesman for the prosecutor's office in Ansbach said the attacker's motive wasn't clear.

"Whether there is an Islamist link or not is purely speculation at this point," said the spokesman, Michael Schrotberger.

The man had been refused refugee status in Germany a year ago, a top security official in Bavaria, where the incident took place, said early on Monday. An interior ministry spokesman later said he had been scheduled to be deported to Bulgaria.

Bavaria Interior Minister Joachim Herrmann said the man had tried to commit suicide twice before.

"We don't know if this man planned suicide or if he had the intention of killing others," Herrmann said.

Three of the 12 wounded were seriously hurt, police said.

Herrmann said the man had apparently been denied entry to the Ansbach Open music festival shortly before the explosion, which happened outside a restaurant called Eugens Weinstube.

He added that, despite his asylum request being denied, the man had been allowed to remain in Germany because of the war in Syria.

Europe on edge

"He came to Germany two years ago and his asylum application was rejected last year for reasons that we don't know right at this minute," Al Jazeera's Dominic Kane, reporting from Berlin, said.

"He had been based in Germany with the knowledge that he was not going to receive permanent asylum in this country. He had twice before tried to take his life and he had at some point in the recent past been receiving psychiatric help."

READ MORE: Munich shooting - 10 killed in shopping centre attack

The blast is the third incident to hit the southern state of Bavaria in a week, after nine were killed in a shooting rampage in Munich and several were wounded in an axe attack on a train.

A large area around the site of the explosion in the city of around 40,000 people was still sealed off hours later. More than 2,000 people were evacuated from the festival.

Europe has been on edge for months after a string of deadly attacks claimed by the Islamic State of Iraq and the Levant (ISIL, also known as ISIS), including bombings in Brussels and carnage at Bastille Day celebrations in the southern French city of Nice.

Police said neither Sunday's machete attack nor Friday's shooting in Munich showed any signs of being connected to ISIL or similar groups.

ISIL claimed responsibility for the July 18 axe attack in Germany, and for the July 14 attack in which a Tunisian man drove a truck into Bastille Day holiday crowds in the French city of Nice, killing 84 people.