The incident happened at around 10am on Thursday in Dumfries and Galloway.
Police Scotland said the boy suffered a “superficial injury” in the incident.
Officers recovered a blade and the girl was arrested.
A report is to be sent to the procurator fiscal.
A Dumfries and Galloway Council spokesman said: “The incident was dealt with quickly and appropriately. The school operated normally for the rest of the day.
“Police Scotland is investigating the matter and a report is being prepared for the procurator fiscal.
“It would be wholly inappropriate for us to make any further comment.”
Local councillor John Martin said: “It’s a very rare occurrence and I just hope it won’t happen again.”
Conservative Dumfriesshire MSP Oliver Mundell said: “It is always disturbing to learn of any such incident in a school, particularly one in my own constituency.
“Thankfully such reports are rare and the police will have to complete their investigation to establish the circumstances.
“My thoughts are with pupils, staff and parents at a difficult time.”