Two boys have been killed near a primary school in Shanghai after a 29-year-old man attacked a group with a kitchen knife, according to local media.

At about 11.30am local time (0430 GMT) on Thursday, police in the Chinese city’s Xuhui district received a report that three boys and a female parent had been attacked by a man in the street near Shanghai Shiwai elementary school. The four victims were taken to hospital. Two of the boys died.

A witness told Beijing News the assailant was caught by pedestrians and an air conditioner repairman helped restrain him. A video posted by the news outlet showed a man lying face down, with his feet and wrists bound together with rope. A crowd of people stood around him, one with his foot on the back of the man’s head.

In the video, bystanders can be heard shouting “Beat him to death”, and “He’s a psycho”. The video also showed adults crouched over an injured boy.

Police said the assailant was an unemployed man identified only by his surname, Huang. He was detained at the scene, according to the Shanghai-based daily the Paper.

The incident has renewed fears about safety at Chinese schools, after a number of attacks by knife-wielding men over the past decade.

Nine schoolchildren in Shaanxi province were stabbed to death in April by a 28-year-old man. After a series of attacks in 2010, authorities increased security at schools.