The attack is believed to have taken place in toilets at the school in Shepherd's Bush, west London, on Tuesday afternoon. Four 10-year-old boys and one aged nine were arrested and questioned about what happened. They were released on bail to return next month while detectives make more inquiries.
The girl is being given counselling, while the other 176 pupils at the school are also being offered help.
The five boys, all pupils at the school where the alleged attack took place, have been suspended. Social services is also providing counselling for the boys and their parents.
A spokeswoman for the local education authority, Hammersmith & Fulham, said security at the building was being reviewed. She added: "It is perhaps more an issue of supervision as the alleged incident involved pupils from the school rather than outsiders."
She continued: "The main task of the school today is to provide as normal a day for the children as is possible. Pupils are being offered counselling."
On the same day, a 12-year-old schoolgirl was raped after being set upon by a group of youths on a disused railway line in Wolverhampton. Police said the girl was indecently assaulted by three boys and then raped by one of them.
Det Insp Dave Whatton, of West Midland Police, said at least five boys were present when the girl was pushed to the ground and raped.
It is believed that several boys among the group were onlookers and did not attack the 12-year-old.
Det Insp Whatton added: "This is a very serious incident, not least because of the very young age of the victim and the ages of the alleged offenders. It is frightening and disturbing to think that children are involved in sex attacks."
Three boys aged 13 and 15, are being questioned by police.
The law has recently been changed to allow 10-year-olds to face charges of rape. Nine-year-olds and younger cannot be held criminally responsible.
The current debate about school violence was sparked by the murder of the headmaster Philip Lawrence, outside his school in Maida Vale, north- west London, in 1995.
However it was not until Thomas Hamilton's massacre of 16 children and a teacher at Dunblane last March that the Cullen inquiry was convened.
It recommended that every school should have CCTV, panic buttons and personal alarms for teachers.Reuse content