A 27-year-old Syrian man who had been denied asylum in Germany a year ago died on Sunday when a bomb he was carrying exploded outside a music festival in Ansbach, Germany, a Bavarian state official told a news conference, according to a website.

Bavaria Interior Minister Joachim Herrmann said the man had tried to commit suicide twice before. It was unclear if he had planned to commit suicide or "take others with him into death", the Nordbayern.de website reported. Twelve people were wounded in the attack.

Herrmann said the man, carrying a backpack, had apparently been denied entry to the Ansbach Open music festival shortly before the explosion, the website reported. More than 2,000 people were evacuated from the festival after the explosion, police said.

It was the fourth violent incident in Germany in a week and came as the country was still on edge after the killing of nine people by an 18-year-old Iranian-German gunman in Munich on Friday.

A large area around the site of the explosion, in the city of around 40,000 people, was still sealed off hours after it occurred outside a restaurant called Eugens Weinstube.

Three of the people injured were reported in serious condition.

Ansbach is home to a U.S. Army base and the 12th Combat Aviation Brigade. A spokesman at the base said the base had no information about the explosion.

Earlier on Sunday, a 21-year-old Syrian refugee was arrested after killing a pregnant woman and injured two other people in the southwestern city of Reutlingen, near Stuttgart.

That attack came after a refugee from Pakistan wielding an ax injured five people near Wuerzbuerg, also in southern Germany, before he was shot dead by police on July 18.

Police said neither Sunday's machete attack nor Friday's shooting in Munich bore any sign of connections with Islamic State or other militant groups.

Islamic State claimed responsibility for the July 18 ax attack in Germany. It also claimed responsibility 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.