A 20-year-old grade 10 pupil went on a killing rampage with an axe in Mayflower, near Ermelo in Mpumalanga on Sunday, allegedly killing three people, including a six-month-old baby, and injuring 12 others.

The man, who is suspected of suffering from a mental illness, allegedly used a medium-sized axe, to hack a 70-year-old woman, as well as a 16-year-old mother and her six-month-old baby girl to death, said police spokesperson Captain Sabelo Mlangeni on Monday.

"The family called the police on Friday, saying that he was violent, but after the police and ambulance arrived he calmed down and was released," Mlangeni said.

The suspect again became violent on Sunday morning and his family had to tie him up with rope and left him on the floor, Mlangeni said.

"He somehow untied himself. He got an axe and attacked his brother before he went out into the street and started hacking people in the street," Mlangeni said.

In all, 12 people, ranging from children as young as 10-years-old to adults, were seriously injured and taken to hospital.

The man then went into the house of the 70-year-old woman who lived alone and allegedly hacked her in the head. The woman died on the scene.

"He then went out into the street again and hacked the baby, who was carried on her 16-year-old mother's back, in the head before he hacked her mother to death," Mlangeni said.

When the police arrived, the man was armed with a shovel. One of the three police officers who responded was hacked in the hand, while trying to restrain the suspect.

"By this time the community was mobilised and the police had to protect him (the suspect) because they wanted to prise him from the van and take revenge on him," Mlangeni said.

The man, who was wounded in the head during the attacks, was taken to hospital under police protection, but was released into police custody on Monday morning.

He will appear in the Mayflower District Court on three counts of murder and 12 counts of attempted murder and he will be sent to the Weskoppies Psychiatric Hospital for evaluation. - Sapa