The child and her mother were on their way to a metro rail station to meet the girl’s grandfather when the incident took place.
The attacker grabbed the girl from behind and beheaded her with a cleaver, the child’s mother said.
A 33-year-old man named by police as Wang Ching-yu was arrested following the incident.
An angry crowd gathered outside the police station where Wang had been taken, and tried to attack the suspect.
According to police, the suspect was given treatment at a local psychiatric hospital and had been charged with drug possession.
On Tuesday, local residents laid flowers and cards at the crime scene in honour of the victim.