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 14 killed in explosion at weapons depot in Syria
US hits five Iranian oil tankers after attack on Navy ships
UK gives air traffic provider a week to probe outage that halted flights
Serbia's President Vucic dissolves parliament, calls snap elections
With large crowds attending, Norway lays King Harald to rest
Jordan intercepts 18 Iranian ballistic missiles
Air traffic control issue disrupts flights at major UK airports
At least 73 injured after Houthi rebels attack Saudi civilian and energy facilities
