BERLIN (AP) — A gunman took three people hostage at the city hall in the Bavarian city of Ingolstadt on Monday, officials said, and the standoff forced Chancellor Angela Merkel to cancel an election rally there.

The hostage-taker was a young man armed with a handgun, though it wasn't clear whether it contained live ammunition, police spokesman Hans-Peter Kammerer said. The incident started shortly before 9 a.m. (0700 GMT) Monday and police were in contact with the man by telephone.

One of the hostages was a deputy mayor, Sepp Misslbeck. He was freed some five hours into the standoff, police spokesman Josef Petzenhauser.

It wasn't immediately clear how he was released. The gunman was still holding two hostages — a man and a woman.

Bavaria's state interior minister, Joachim Herrmann, said the hostage-taker had previously stalked a female employee at the city hall, German news agency dpa reported.

Mayor Alfred Lehmann said the man "wants us to reverse a decision." He said it wasn't immediately clear what decision he meant, but he may have been referring to the fact he had been barred from Ingolstadt's city halls.

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.

The hostage-taking happened several hours before Merkel was due in the city for a late afternoon rally that was to take place on the square in front of the city hall. Germany holds national elections on Sept. 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, Merkel's conservative Christian Democratic Union said it decided to cancel the rally.

Ingolstadt is located some 44 miles (70 kilometers) north of Munich and has about 125,000 inhabitants.