Updated

One person has been killed and three others injured in a shooting at a nightclub in southern Germany.

Witnesses told German news agency dpa that the attacker had a machine gun and shot at the crowd inside the building indiscriminately, local media reported.

Terrified revellers fled the music venue or hid as the shooter opened fire at around 4:30 a.m.

The 34-year-old Iraqi gunman exchanged fire with police before he was shot at the scene by armed officers.

Germany Nightclub 2

A visitor, center, waits to be questioned by police near a discotheque in Constance, at Lake Constance, Germany, Sunday, July 30, 2017. (Felix Kaestle/dpa via AP)

The critically injured shooter was taken to hospital where he later died.

A police officer was also injured in the gunfight outside Club Grey in the southern German city of Konstanz. His injury is not thought to be life-threatening.Officials said special commando forces and helicopters had been deployed to the area.

An investigation has been launched into the attack, the motive for which is unclear, but police have ruled out terrorism.

"We are still investigating but the circumstances surrounding the events at the disco in the evening before the shooting are a bit clearer and this led us to rule out a terrorism background," police spokesman Fritz Bezikofer told broadcaster n-tv.

He added the Iraqi national suspect was not an asylum seeker.

Sunday's shooting comes just two days after a knife attack in the northern German port city of Hamburg.

Germany Nightclub 3

Police and witnesses wait in front of a discotheque in Constanc, at Lake Constance, Germany, Sunday, July 30, 2017. (Felix Kaestle/dpa via AP)

A failed Palestinian asylum seeker killed one person and injured six others at a supermarket on Friday.

Officials said the 26-year-old suspect suffered psychological problems and was "known as an Islamist but not a jihadist".

Read more from Sky News.