Police say a knife attack on a train in northern German late Wednesday followed a dispute between two men, prompting a female officer to intervene and fatally shoot the attacker.

Flensburg police said Thursday that a 24-year-old Eritrean asylum-seeker attacked a 35-year-old man with a knife on a long-distance train heading to the city on the Danish border, injuring him.

A 22-year-old female police officer, who happened to be traveling on the same train, tried to intervene but was then also injured by the attacker. According to the initial investigation, the officer used her weapon and killed the attacker during the incident Wednesday night.

Police said terrorism didn't appear to be a motive in the attack. They did not release further information on the three people's identities.