BERLIN — Targeting foreigners, a man repeatedly drove his car at pedestrians celebrating New Year’s Eve in western Germany, injuring four people before being arrested, the police and prosecutors said Tuesday.

The suspect made comments disparaging of foreigners when the police detained and questioned him, Herbert Reul, interior minister for the state of North Rhine-Westphalia, where the attacks took place, told reporters on Tuesday.

“This is a case of a German deliberately driving into groups of people, people who for the most part were foreigners,” Mr. Reul said. “That means this man clearly intended to kill foreigners.”

At least three adults and one child, among them a Syrian and an Afghan, were struck and severely injured, officials said.