Officers leave Rigby Middle School after a shooting in Rigby, Idaho on Thursday, May 6, 2021.
CNN  — 

Two students and one adult suffered non-life-threatening injuries during a shooting at Rigby Middle School in Rigby, Idaho, on Thursday, according to a statement from the school district obtained by CNN affiliate East Idaho News.

The suspect, a 6th-grade student, pulled a handgun out of her backpack and started shooting in a hallway before going outside, said Jefferson County Sheriff Steve Anderson. A teacher was able to take away the student’s gun, ending the shooting, Anderson said.

“During the shooting, a teacher disarmed the student and detained her until law enforcement took her into custody,” Anderson said at a news conference Thursday afternoon.

The suspect is in custody, he said.

Students were evacuated to a nearby high school where parents were asked to pick them up, according to a statement from the Jefferson County School District.

“This is the worst nightmare a school system can face,” said district superintendent Chad Martin.

Officials don’t have a motive for the shooting in Rigby, a small city about 15 miles north of Idaho Falls.

Jefferson County Prosecutor Mark Taylor said once the investigation is completed his office “will be filing appropriate charges, possibly including three counts of attempted murder.”

People embrace after a school shooting at Rigby Middle School in Rigby, Idaho, Thursday, May 6, 2021.

The two injured students will be kept in the hospital overnight, according to Dr. Michael Lemon with Eastern Idaho Medical Center. The adult has been released from the hospital .

All schools will be closed Friday in response to the shooting, the school district said Thursday afternoon, but counselors will be available at Rigby High School throughout the day.

Idaho Gov. Brad Little said he was being updated on the situation and was praying to “those involved in today’s tragic events.”

“Thank you to our law enforcement agencies and school leaders for their efforts in responding to the incident,” Little said in a Facebook post.

CNN’s Paul P. Murphy and Sara Finch contributed to this report.