The train was traveling near the city of Aachen, in North Rhine-Westphalia, in the far west of the country, at around 7.40am local time when a man began attacking fellow passengers “randomly and arbitrarily”, state interior minister Herbert Reul said.
An Iraqi-born man has been arrested in relation with the attack.
Police said the 31-year-old suspect had been overpowered by a police officer who happened to be on the train, and two other passengers.
The unnamed officer said: “I was on my way to work, that’s all I can say.”
Five people plus the attacker were wounded but only four needed hospital treatment and were being looked after locally. None of them were said to be in a critical condition.
Mr Reul said it was a “gruesome crime that was stopped in an enormous act of courage”.
The interior minister added that the suspect was already known to authorities. However, he added that authorities have not confirmed that the suspect had an Islamist motive for the attack.
There were about 270 passengers on the regional train which was close to Herzogenrath at the time of the attack.
The track has been closed while investigations continue and around 200 officers were at the scene.