A student fired multiple gunshots inside Ply­mouth Middle School on Monday in a frightening incident that ended with parents hugging their children in relief when word spread that no one was injured.

The shots rang out about 8:45 a.m. outside a bathroom, and a school resource officer apprehended the student, said Plymouth Police Chief Erik Fadden. The gun was recovered, Fadden said.

The sixth-grader took the handgun from his father's bedroom and brought it to school, the man told the Star Tribune.

The school, just west of Hwy. 169 on 36th Avenue N., went into a lockdown for the rest of the morning as hundreds of parents gathered in the parking lot of nearby Armstrong High School, waiting to pick up their children. Many of them were wiping tears or bent over their phones, texting their students for updates.

During a news conference, Interim District Superintendent Stephanie Burrage thanked parents for their patience as the school worked to count students before releasing them to families.

"We had an unfortunate situation today," she said. "Anytime there is a gun in the school, [that] puts our kids in jeopardy. ... It's not a fun day for anyone to manage a gun in a school."

School resource officers working in Plymouth wear plainclothes and are equipped with a Taser, firearm and body camera, said police spokeswoman Karen Anderson. The boy was detained without use of any lethal or nonlethal deployment.

The shots were fired into the ceiling, the school said in an online update.

"Thank God there was a school resource officer there to de-escalate," said Hennepin County Sheriff David Hutchinson, whose office assisted police on Monday.

The suspect's father, who talked to his 12-year-old son at the school afterward, said he hadn't noticed anything different in the boy's behavior. He also specified that he did not believe the shooting was racially motivated.

Later in the day, Burrage sent the school community a message to dispel a rumor that the boy had denounced Black Lives Matter. "That is totally false information," she said.

The Star Tribune is not identifying the man to protect his juvenile son's identity. Leaving the gun accessible to a minor could expose the man to prosecution.

"I think he realizes the mistake he has made," the father said. "I hope they can get him the help he needs."

The district declared that Tuesday will be a distance learning day, to give "families and staff the space and time to process the events of today."

Students who left the school after the shooting were escorted by law enforcement and school staff.

Avery Oseth, 13, said he heard shots during a passing period. "I knew right away what that sound was," he said. "I just started running. There was so much adrenaline."

He was pulled into a seventh-grade classroom, where the class quickly went into lockdown.

Oseth's stepfather, Eric Bouchey, found out about the school shooting in a text from his brother, who was asking if Bouchey's daughter and stepson were OK. "My heart just sank," Bouchey said as his eyes filled with tears. It was more than an hour before he heard from his daughter.

"It's just so surreal," he said as he waited for his 13-year-old daughter to come out of the school. "Even though I know she's safe, it's really hard to wait to see her."

Katoria Turner, an eighth-grader, said she froze in the hallway when she heard the gunfire.

"I think I just shut down," she said. Then she made her way to her math class.

Hours later, she was able to hug her mom, Traci Mahoney, who told someone who called her cellphone to check in: "I got my baby! I feel like I can breathe again."

Seventh-grader Lola Hodgson texted her mother, Nikia Slaughter, at 8:47 a.m. that the school was on lockdown and that shots had been fired.

Later in the morning, Slaughter and her mother, Karen Jetson, were waiting in the Armstrong parking lot for Hodgson.

The news at 10 a.m. that no one was hurt appeared to bring an overwhelming sense of relief.

"My hands finally stopped shaking," Slaughter said.

"This is the best outcome of the worst situation," Jetson said.