The official said the man seemed to be in an "exceptional psychological situation" and there were no indications that this was a terrorist-related incident.
The man is thought to be the son-in-law of the owner of the restaurant, the official said. He is originally from Macedonia but has lived in Germany for many years, he added.
He also said the man was not believed to be holding anyone hostage and a special team of negotiators were trying to speak with him. It remained unclear how he injured himself.
Bild newspaper said that the man had run into the restaurant "Dubrovnik" in the town centre and shouted that everyone should leave.