A 29-year-old man attacked three boys and one woman using a meat cleaver near a school in Shanghai on Thursday, killing two of the children, police said.
The suspect launched the assault at around 11:30 a.m. and was caught by police with the help of passers-by.
Police said the attacker, new to Shanghai and unemployed, carried out the attack 'to take revenge on society'.
Further investigations are underway. Two of the boys died at the hospital.
Another boy and the woman survived and did not have life-threatening injuries.
The woman is said to be a family member of a pupil, but it remains unclear if she is related to any of the boys that were killed or injured.
The attack took place on Pubei Road near Guilin Xi Jie in Shanghai's Xuhui District, according to the Xuhui district public security office on its official Sina Weibo microblog page.
The location is near the Shanghai World Foreign Language Primary School, but police are yet to confirm whether or not the boys were pupils attending the school.
Police said the male suspect, surnamed Huang, arrived in Shanghai earlier this month and was unemployed.
Police were alerted of the attack and immediately arrived at the scene.
Footage released by Beijing Youth Daily on Weibo shows the moment how the suspect was captured by officers, helped by bystanders.
Other pictures circulating on the social media platform show victims lying on the street covered in blood.
The four victims were rushed to the hospital. Because Chinese law tightly restricts the sale and possession of firearms, mass attacks are generally carried out with knives or homemade explosives.
Perpetrators of similar attacks in the past have been described as mentally ill or bearing grudges against society.
Many of those incidents have occurred at schools, including several in 2010 in which nearly 20 children were killed, prompting a response from top government officials and leading many schools to beef up security.
A similar attack in April in Mizhi, Shaanxi Province, saw seven schoolchildren killed and another 12 injured by a knife-holding man on their way back home.
It was reported the 28-year-old man had been bullied while studying at the school, therefore carried out the revenge attack.