According to state-run news agency Xinhua, a 23-year-old suspect surnamed Kong climbed into the school in Kaiyuan city, Yunnan province, on Monday afternoon and sprayed caustic soda on a room full of students and teachers.
Two of those hit were seriously hurt, although their injuries are not life-threatening, the report said.
The suspect was detained about an hour after the attack. He allegedly sprayed the chemical as an act of revenge on society, Xinhua quoted police as saying.
Caustic soda -- also known as sodium hydroxide -- is used in the manufacturing of a number of common products, including soap, paper, and various dyes.
According to the United States' Centers for Disease Control and Prevention, exposure to caustic soda can irritate or burn the eyes and skin, provoke an allergic reaction, or even cause temporary hair loss.
History of violence
Monday's incident is not the first school attack to take place in China. In October 2018, a woman wielding a kitchen knife slashed at least 14 children at a kindergarten in the central city of Chongqing.
Nine students were killed at a middle school in Shaanxi province in April 2018 by a 28-year-old man who was later sentenced to death.
In 2017, 11 students were injured after a man climbed over the wall of a kindergarten with a knife and began attacking them.