A 49-year-old man has been arrested after attacking 20 children at a primary school in Beijing with a hammer.

Key points: The suspect is a man who performed maintenance at the school

The suspect is a man who performed maintenance at the school The suspect allegedly wielded a hammer he normally used for work during a class

The suspect allegedly wielded a hammer he normally used for work during a class Three students suffered heavy injuries, but authorities say their conditions are stable

The Xicheng district government said in a post on its Weibo account three of the children suffered heavy injuries and were in a stable condition. There were no reports of any deaths.

Local police also said on Weibo the attack took place at Xuanwu Normal Experimental Affiliated Number One Primary School at 11:17am (local time).

The suspect, surnamed Jia, was apprehended at the scene, the statement said.

A native of northern Heilongjiang province, Mr Jia was employed through a labour service company to perform daily maintenance work at the school.

His contract was set to expire this month and had not been renewed.

Police initially did not give other details of the attack, and earlier reports suggested both that the suspect used a knife and that children suffered knife wounds to the head.

But Xicheng district later said Mr Jia wielded a hammer that he normally used for work to injure students during a class as an expression of his dissatisfaction.

Outside the school gates on Tuesday afternoon, parents who were there to pick up their children said they had received little information about the attack.

"I was terrified," an elderly man who only gave his surname, Xie, said. His grandson is a second-grader at the school.

"[The school] didn't tell us anything."

"It would be fine if he attacked us old people, but kids are young and innocent, and they don't know how to defend themselves."

Many schools in China have increased security following violence against students and family members.

In 2010, nearly 20 children were killed in knife attacks outside school gates.

Last April, nine people were killed outside a middle school in north-western China, allegedly by a former student seeking revenge for having been bullied.

In November, five people were killed when a car was driven into a crowd of children outside a north-eastern Chinese kindergarten.

Wires/ABC