The 24-year-old walked into the town hall of Ingolstadt, north of Munich, at 9am yesterday, hours before Chancellor Angela Merkel was due to hold a rally in the same place.
His captives included the deputy mayor and a woman he had been stalking. It sparked a nine-hour stand-off with police.
But in the afternoon officers decided to enter the town hall and gun shots were heard. ZDF public television reported the man, a former psychiatric patient, suffered two bullet wounds and was taken to hospital.
He had been armed with an imitation handgun and a large knife.
The deputy mayor, Sepp Misslbeck, who was the second of the four hostages to be released recalled that the man told him: "Old man, you are the first who'll get a bullet in the head today.”
The man freed one female captive almost immediately, and five hours later also let Misslbeck go, but kept two others, including the 25-year-old receptionist he had been stalking.
More than 200 police had cordoned off the historic town centre and police and a psychiatrist kept negotiating with the man, whose only demands were for a doner kebab and cigarettes.
Merkel had been due to speak at an afternoon rally of her conservative Christian Democratic Union outside the town hall, along with her political ally, Bavarian state premier Horst Seehofer, who is also running for re-election next month.
Seehofer later praised police, saying "they reacted in a professional, consistent and prudent way and they saved the lives of the hostages".