Three people have been shot after a young girl brought a gun to her school and opened fire.

The girl was in a school hallway on Thursday morning when she pulled a handgun from her backpack and fired multiple rounds at Rigby Middle School in Idaho.

Two people were hit inside before she went outside and injured a third.

The student – who in sixth-grade and aged 11 or 12 – was disarmed by a teacher who held her until police arrived.

Student Yandel Rodriguez, 12, said: “Me and my classmate were just in class with our teacher – we were doing work – and then all of a sudden, there was a loud noise and then there were two more loud noises.

“Then there was screaming. Our teacher went to check it out, and he found blood.”

The three victims – two students and a member of staff – are expected to survive.

More on Idaho

The girl, who has not been named and is from nearby Idaho Falls, is in custody.

It is unclear where she got the gun and why she shot at people, said Jefferson County Sheriff Steve Anderson.

“We don’t have a lot of details at this time of ‘why’ – that is being investigated,” he added. “We’re following all leads.”

Jefferson County Prosecutor Mark Taylor said decisions about criminal charges will not be made until after the investigation, but they could include three counts of attempted murder.

The school shooting appears to be only the second in Idaho: in 1999 a high school student in Notus fired a gun several times, with one student injured by ricocheting debris.