BEIJING — A car plowed into a crowd of children outside a primary school in northeastern China on Thursday, killing five people and injuring 18, a local government spokesman said.

The driver was taken into custody after the crash around noon in the coastal city of Huludao in Liaoning province, said the spokesman for Jianchang county in the city's suburbs, who declined to give his name as is standard with Chinese bureaucrats.

He described the crash as "a major traffic accident" and said the cause was under investigation.

State broadcaster CCTV reported all five dead and all but two of the injured were children.

Security camera footage showed a line of children crossing the street in front of their school when a car approaches, which then changes lanes and swerves into the crowd of children.

It wasn't clear if the crash was a deliberate attack or whether the driver was swerving to avoid obstacles in front of him.

Wang Mingkuan, a cook at a nearby noodle restaurant, said he was making meals when the crash occurred.

"I ran out and saw about a dozen children lying on the ground, some of them bleeding, all about 7 or 8 years old. Two or three showed no signs of life," Wang told The Associated Press by telephone.

Wang said ambulances and police cars rushed to the scene and officers blocked off the area and prevented people from filming. He said that rumors about the driver included that he was drunk, fleeing police or had deliberately targeted the children.

Last month, a knife-wielding man drove a vehicle into a crowd of pedestrians in the eastern city of Ningbo, killing two people and wounding 16.

And in September, 11 people were killed and 44 hospitalized after a man drove an SUV deliberately into people at a plaza in the central province of Hunan, before jumping out and attacking victims with a dagger and shovel.

Other deadly attacks have occurred at or just outside schools, including several in 2010 in which nearly 20 children were killed, prompting many schools to beef up security.

However, in June, a man used a kitchen knife to attack three boys and a mother near a school in Shanghai, killing two of the children. Last year, police said a man set off an explosion at the front gate of a kindergarten in eastern China, which struck as relatives gathered to pick up their children at the end of the day, killing eight people.

The attackers' most common motivations are identified as mental illness or alienation from society and a desire to settle scores.