A gunman who took three people hostage at a German city hall, forcing chancellor Angela Merkel to cancel a planned election rally there has been captured and his captives rescued unharmed.
The hostages included a deputy mayor of the Bavarian city of Ingolstad, who was released first. German news agency reports said the gunman had previously stalked a female employee at the city hall.
The incident began several hours before Mrs Merkel was due in the city for a rally that was to take place on the square in front of the city hall. Germany holds national elections on September 22, and Bavaria votes in a state election a week earlier.
There was no indication of any connection between the visit and the hostage-taking. However, Mrs Merkel's conservative Christian Democratic Union said it decided to cancel the rally. The old city hall, one of two city halls in Ingolstadt, dates back to the 14th century, though the building was expanded in the 19th century. It is home to the mayor's office and the city's tourist information office, among other administrative departments.
Police ended the standoff by storming the building, shooting and wounding the captor, and freeing his captives unharmed.
Officials said the 24-year-old kidnapper had previously been banned from entering the city hall because he was stalking one of its employees. The 25-year-old woman was one of the people he was holding hostage.
The kidnapper, whose identity was not released, "was shot in his shoulder and legs" and taken to hospital, police spokesman Guenther Beck said. Two other people the captor had taken hostage, including a deputy mayor of Ingolstadt, were freed from the building earlier in the day, police said.
The kidnapper "was carrying a plastic gun which looked like a real weapon and a big knife" - which is why police were forced to use their weapons, Ingolstadt police said in a statement. Psychologists are counselling the four released hostages.
The German news agency dpa said the stalking victim had been harassed for more than a year. "The captor had an order to stay away from city hall and thought he could force his way back in to be closer to the woman he stalked," Mr Beck said. "It was a classic case of stalking." Police said the attacker was homeless and had been in psychiatric treatment until last month. In cases unrelated to the stalking, the man had previously been convicted of personal injury and harassment.
More than 200 police officers surrounded city hall for nearly nine hours before the special unit raided the building. Forty firefighters and 50 paramedics were also on the scene during the standoff.