A 27-year-old Syrian refugee who was denied asylum a year ago killed himself and injured 12 others after detonating a bomb close to an open-air music festival in the city of Ansbach, near Nuremberg in Germany, late Sunday night.

Three of the 12 injured are in a serious condition. Around 2,500 people were evacuated from the venue and the festival was cancelled following the explosion, which took place outside a restaurant called Eugens Weinstube around 8:12 p.m. GMT.

Bavaria's Interior Minister Joachim Hermann said that the man set off a backpack device after being denied entry to the festival. He had also tried to commit suicide twice before and was known to the police. He had also been admitted to a psychiatric care facility in a district hospital in Ansbach.

Even though his request for asylum was rejected, he was allowed to stay in Germany on a temporary basis considering the situation in his home country. He had also been given an apartment to stay in Ansbach, the minister added.

"We don't know if this man planned on suicide or if he had the intention of killing others," Hermann was quoted by BBC as saying, while adding that he was "incensed" by the attack and it was clear that the country needed "to strengthen controls on those we have living in our country."

Hermann also said that the possibility of a terrorist attack could not be ruled out because the Syrian man's backpack contained pieces of metal used in "wood manufacturing" and could have killed or injured many more people, the Guardian reported.

The interior minister further added that that around 200 people, along with 350 rescue workers and firefighters were involved in the rescue operation.

This is the fourth attack in the country in a week after nine people were killed by an 18-year-old gunman in Munich on Friday.

A Pakistani refugee injured five people in southern Germany by wielding an axe before he was killed by the police on July 18.