A 45-year-old man in an apparent child custody dispute was the suspected shooter at a shelter for mothers and children in northern Germany that left six dead on Monday, officials said.
The man had an appointment at the shelter in Stade, close to the port city of Hamburg, earlier on Monday before opening fire midday, they said.
All the victims - four women and two men - were employees of the facility. The man's three-month-old daughter and the mother are safe.
The alleged shooter, the mother, and another female are in custody, officials said.
"I'm deeply shocked by the extent of violence in a place that is meant to provide protection," said German President Frank-Walter Steinmeier.
Police had warned people to stay away from the area where the incident took place, but later said there was no danger to the general public.
Police cordoned off the area near the facility in a cobbled street with red brick homes, and forensic experts in white suits and plainclothes police were at the scene. Police were still collecting evidence on Monday evening.
Five of the victims died at the scene. The sixth died in hospital.
Footage released by the Bild newspaper showed police surrounding and detaining two people from a car that was driving down a road with a flat tyre.
The suspected shooter lives in the Hannover area, was born in Germany and has Turkish roots, officials said.

At least 9 killed in hotel fire in India's Kolkata
Russian drone attacks kill five in Ukraine's Kherson, governor says
Ebola cases in Congo exceed 5,000, government data shows
8 Israeli airstrikes hit Syria's Abu al-Duhur airbase, state TV reports
Indonesia earthquake death toll rises to 70, government aid arrives
