A man went on a rampage at a primary school in Beijing on Tuesday, stabbing 20 students who suffered wounds to the head, authorities said.

The attack took place at the primary school in Beijing’s Xicheng district just after 11. 15 a.m., the police said on their official Weibo account.

The police statement added that the three students were seriously injured but were in a stable condition.

A film of a meeting between school staff and parents was circulated widely on the social media, in which parents were told a “school worker” had carried out the attack, the South China Morning Post reported.

According to a former school maintenance worker, the attack was carried out by a former temporary janitor at the school who was angry at not having passed his probation.

There were conflicting reports about whether a knife or a hammer had been used in the attack.

“The children were attacked while they were doing exercises on the school running track. The attacker was standing nearby and used a hammer-like weapon to hit the children’s skulls one by one, before he was stopped by a teacher,” said one parent on WeChat.

The suspect was caught at the scene and further investigation was underway, Xinhua news ageny said.