The 27-year-old, who had spent a stint in a psychiatric facility, had intended to target a music festival in the city of Ansbach but was turned away because he did not have a ticket.
"Unfortunately, this is a terrible new attack which will surely increase people's anxiety," regional interior minister Joachim Herrmann said, adding that investigators "have not ruled out" he had an Islamist motive.
Hermann said he was worried "the right to asylum would be undermined" by the events of the past week, which has seen attacks on a train and shopping mall in the southern German state.
Police have blocked off the area and emergency services were at the scene. Bomb experts were also sent to determine the cause of the blast.
More From This Section
Ansbach deputy police chief Roman Fertinger said there were "indications" pieces of metal had been added to the explosive device.
The perpetrator was killed in the explosion, police said in a statement, and a spokeswoman said 12 people were wounded, three of them seriously.
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.
In Bavaria, which has been a gateway for thousands of Syrian refugees, nine died in a shooting rampage in Munich on Friday and several people were wounded in an axe attack on a train near Wuerzburg.
The teen was obsessed with mass killings and spent a year preparing for the gun attack that killed nine people, most of them foreigners.
At least 35 people were also wounded during Sonboly's shooting spree, which began at a McDonald's branch and ended with him turning his 9mm Glock pistol on himself.
Investigators have ruled out any link with the jihadists, though he appears to have planned the assault with chilling precision.