Updated

An alleged disgruntled worker used his hammer to attack 20 children inside a Beijing primary school Tuesday before officials were able to end the rampage and arrest him.

The attacker, identified only by his surname, Jia, wielded the hammer he used for work inside Beijing No. 1 Affiliated Elementary School of Xuanwu Normal School. He injured nearly two dozen students inside a classroom just after 11:15 a.m. Tuesday, officials said.

Three children suffered serious but non-life-threatening injuries, the Xicheng district government said on its social media account. All the children were taken to the hospital and expected to survive.

A man rides with a student past crime scene investigators as they leave the Beijing No. 1 Affiliated Elementary School of Xuanwu Normal School in Beijing, China, Tuesday, Jan. 8, 2019. (AP)

"I was terrified," said a man who identified himself by the surname Xie.

"[The school] didn't tell us anything," Xie said, adding his grandson attends second grade in the school. "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."

Jia, who was hired through a labor service company, worked at the school as a contract maintenance worker. His contract was set to expire this month and had not been renewed.

The Associated Press contributed to this report.