A 12-year-old boy is said to have shot and killed a classmate of his age at a school in South Carolina.

The motive for the crime was initially unclear.

The suspect, from Tanglewood Middle School in Greenville, was arrested and charged with murder and illegal possession of a weapon, among other things, as a person under the age of 18, the sheriff's office said on Thursday evening.

A school security officer heard shots and called for backup around noon.

Emergency services found the victim injured when they arrived.

The boy was taken to the hospital, where he was later pronounced dead.

Police officers found the alleged perpetrator after a search at a residential building and arrested him.

A weapon was seized.

The two boys would have known each other, it was said.

However, the motive initially remained unclear.

Investigators also wanted to find out how the suspect got the gun.