A gunman stormed a service at his former Jehovah's Witnesses congregation in Hamburg, killing six people before taking his own life after police arrived, authorities in the German port city said.
Police gave no motive for Thursday night's attack, which stunned the country's second-biggest city.
But they acknowledged recently receiving an anonymous tip claiming the man showed anger toward religious groups and might be psychologically unfit to own a gun.
Eight people were hurt, including a woman who was 28 weeks pregnant and lost the baby. Chancellor Olaf Scholz said the death toll could rise.
Officers apparently reached the hall while the attack was ongoing and heard one more shot after they arrived, according to witnesses and authorities.
Boy, 10, killed and friend, 9, seriously injured after being hit by trainThey did not fire their weapons, but officials said their intervention likely prevented further loss of life.
Mr Scholz, a former Hamburg mayor, lamented the "terrible incident in my home city".
"We are speechless in view of this violence," he said at an event in Munich.
"We are mourning those whose lives were taken so brutally."
All of the victims were German citizens apart from two wounded women, who had Ugandan and Ukrainian citizenships respectively.
Officials said the gunman was a 35-year-old German national identified only as Philipp F in line with the country's privacy rules.
Police said the suspect had left the congregation "voluntarily but apparently not on good terms" about a year and a half ago.
The man legally owned a semi-automatic Heckler & Koch Pistole P30 pistol, according to police.
He fired more than 100 shots during the attack - and the head of the Hamburg prosecutors office, Ralf Peter Anders, said hundreds more rounds were found in a search of the man's apartment.
Hamburg police chief Ralf Martin Meyer said the man was visited by police after they received an anonymous tip in January claiming he "bore particular anger toward religious believers, in particular toward Jehovah's Witnesses and his former employer".
Riot police evict people from village as it is demolished for new coal mineOfficers said the man was co-operative and found no grounds to take away his weapon, according to Mr Meyer.
"The bottom line is that an anonymous tip in which someone says they're worried a person might have a psychological illness, isn't in itself a basis for (such) measures," he said.
Germany's gun laws are more restrictive than those in the United States, but permissive compared with some European neighbours and shootings are not unheard of.
Last year, an 18-year-old man opened fire in a packed lecture theatre at Heidelberg University, killing one person and wounding three others before killing himself. In January 2020, a man shot dead six people including his parents in southwestern Germany, while a month later, a shooter who posted a racist rant online killed nine people near Frankfurt.
In the most recent shooting involving a site of worship, a far-right extremist attempted to force his way into a synagogue in Halle on Yom Kippur, Judaism's holiest day, in October 2019. After failing to gain entry, he shot two people to death nearby.
The German government announced plans last year to crack down on gun ownership by suspected extremists and to tighten background checks. Currently, anyone wanting to acquire a firearm must show that they are suited to do so, including by proving that they require a gun. Reasons can include being part of a sports shooting club or being a hunter.
On Friday morning, forensic investigators in protective white suits could be seen outside the Jehovah's Witnesses' Kingdom Hall, a boxy, three-storey building next to a car repair shop, a few miles from downtown Hamburg. As light snow fell, officers placed yellow cones on the ground and windowsills to mark evidence.
Hamburg's top security official said a special operations unit that happened to be near the hall arrived just minutes after receiving the first emergency call at 9.04pm. The officers were able to separate the gunman from the congregation.
"We can assume that they saved many people's lives this way," Hamburg state interior minister Andy Grote told reporters.
Upon arrival, officers found people with apparent gunshot wounds on the ground floor, and then heard a shot from an upper floor, where they found a fatally wounded person who may have been a shooter, according to police spokesman Holger Vehren.
Student Laura Bauch, who lives nearby, said there were around four periods of shooting, German news agency dpa reported. "There were always several shots in these periods," she said.
Ms Bauch said she looked out her window and saw a person running upstairs from the ground floor of the hall.
Gregor Miebach, who lives within sight of the building, heard shots and filmed a figure entering the building through a window. In his footage, shots can then be heard from inside. The figure later apparently emerges from the hall, is seen in the courtyard and then fired more shots through a window before the lights in the room go out.
Mr Miebach told German television news agency NonstopNews that he heard at least 25 shots. After police arrived, one last shot followed, he said.
His mother, Dorte Miebach, said she was shocked by the shooting. "It's really 50 metres from our house and many people died," she said. "This is still incomprehensible. We still haven't quite come to terms with it."
Jehovah's Witnesses are part of an international church founded in the United States in the 19th century. It claims a worldwide membership of about 8.7 million, with about 170,000 in Germany.
Members are known for their evangelistic efforts which included knocking on doors and distributing literature in public squares. They refuse to bear arms, receive blood transfusions, salute a national flag or participate in secular government.
David Semonian, a US-based spokesman for Jehovah's Witnesses, said in an emailed statement early on Friday that members "worldwide grieve for the victims of this traumatic event".
"The congregation elders in the local area are providing pastoral care for those affected by the event," he wrote.