HONG KONG — A man attacked and injured 20 children with a hammer on Tuesday at an elementary school in Beijing, the local authorities said.

Three children at the Beijing No. 1 Affiliated Elementary School of Xuanwu Normal School in the district of Xicheng were seriously injured in the late-morning attack, the district government said on the social media site Sina Weibo. But none of the injuries appeared to be life-threatening, it said.

A 49-year-old maintenance worker at the school was taken into custody by the police, the government said. The statement identified the man by his surname, Jia, and said he was from the northeastern province of Heilongjiang. It said he was believed to have attacked the children because the school would not renew his contract.

The man attacked the students between classes with a hammer that he used for repairs, the statement said.