The interior ministry of the state of Schleswig-Holstein, on the Danish border, said the suspect was arrested at a train stop in the village of Brokstedt.

Earlier, the Bild newspaper had said five people were injured in the attack. The number of wounded couldn't immediately be confirmed.

Police were investigating at the train station in Brokstedt, the German railway Deutsche Bahn said on Twitter, adding some services between the two cities had been cancelled.

"Federal and state police are working closely together on investigating this case," state interior minister Sabine Suettelin-Waack said in a statement.

(Writing by Miranda Murray and Thomas Escritt; editing by Rachel More and Bernadette Baum)