A Syrian man who detonated explosives outside a music festival in the German city of Ansbach, killing only himself and wounding at least 15 people, had pledged allegiance to the Islamic State of Syria and the Levant group before the attack, according to a senior government official.