A gunman killed four hostages in southwestern Germany Wednesday before presumably shooting himself while resisting eviction from his apartment building, police said.

Police said they found five dead bodies in the apartment in the city of Karlsruhe after storming it when they smelled something burning, about three hours after the hostage-taking began.

Authorities initially spoke of three or four dead but said they discovered the body of a fifth victim, a woman, presumed to be the owner of the flat, during a search, a spokesman said.

Two of the others included a bailiff and a locksmith. Two further bodies have yet to be identified but are thought to include the hostage-taker who police earlier said was heavily armed.

Residents of the building had raised the alarm with police at around 9:00 am (0700 GMT) when shots were heard from the home of the hostage-taker who was about to be evicted.

The fifth-floor flat was at the top of an apartment building in a leafy, middle-class neighbourhood, a few kilometres (miles) north of the city centre.

About 200 police officers were sent to the scene including about 40 members of elite police units, and the area was sealed off.

Two schools and kindergartens are located nearby and several apartment blocks were evacuated, according to the local daily Badische Zeitung.

Police were due to hold a news conference at 1400 GMT.

Authorities had established the identity of the hostage-taker before announcing the deaths and said they were trying to make telephone contact with him. It was not known if they succeeded.

No details were available on the hostage-taker's weapons but rolling news channel NTV reported he had at least one hand grenade.

Justice minister of Baden Wuerttenberg state Rainer Stickelberger said he was "deeply distressed". "We must do everything we can to shed light on the terrible crime as quickly as possible," he said.

German gun laws were tightened after two school massacres in the eastern city of Erfurt in April 2002 and in the southwestern town of Winnenden in March 2009, both of which were also carried out with legal weapons.

In January, a 54-year-old defendant accused of embezzlement shot dead a prosecutor at a court in the southern German city of Dachau.