A man claiming to be carrying a gun took three hostages in the town hall of a German city where Chancellor Angela Merkel had been due to give a campaign rally later in the day.

Merkel cancelled her event following the hostage-taking, as police negotiated with the man, who after five hours freed one of the captives, a deputy mayor of the town of Ingolstadr north of Munich.

The incident started shortly before 9 am (0700 GMT) on Monday.

The gunman was still holding two hostages, a man and a woman, the police said.

The hostage-taker was a young man armed with a handgun, though it wasn't clear whether it contained live ammunition, police said.

"The man wants us to reverse a decision,  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," Mayor Alfred Lehmann said.