They said a man used a knife in the attack, injuring passengers shortly before the train, travelling from Kiel to Hamburg, arrived at Brokstedt station.
Two of the victims died after the attack, police spokesman Juergen Henningsen said.
Three people were severely injured and four suffered minor injuries. No details were given about the identity of the victims.
A suspect aged between 20 and 30, who sustained injuries was taken into custody at Brokstedt railway station, police said.
They are trying to determine a motive for the attack.
The Interior Minister of Schleswig-Holstein state, Sabine Suetterlin-Waack, confirmed the number of people killed and injured.
“It is terrible,” Ms Suetterlin-Waack said. “We are shocked and horrified that something like this has happened.
“For me, it is clear that this horrific act was against any humanity."
Federal and regional police were at the scene and the prosecutor’s office is investigating the attack, broadcaster NDR reported.
The train station in Brokstedt was closed for several hours and train traffic was delayed across northern Germany.
Train operator Deutsche Bahn expressed its condolences on Wednesday evening, saying: “Our deepest sympathy goes to the relatives of the victims. We wish those injured a speedy and complete recovery.”