A 10th grader at Glen Burnie High School in Anne Arundel County brought a .22-caliber handgun loaded with seven rounds onto campus Tuesday, carrying the weapon in his backpack before he was stopped and searched, police and school officials said.

The 15-year-old did not threaten others and was taken into custody without incident shortly after noon, officials said. Police are still investigating why he had the weapon and where he got it.

Officials searched the teen’s book bag after he left campus and tried to return, drawing the attention of a school secretary. School administrators questioned the student, and his answers did not add up, officials said.

Schools spokesman Bob Mosier said there was no indication the 10th grader intended to use the gun, but Mosier credited school employees and a school-based police officer for following safety practices.

“Even though there was no threat made here, they helped avoid what clearly could have been a disastrous situation,” Mosier said. “You have a gun that had seven bullets in it. Clearly something could have gone horribly wrong.”

The student was charged as a juvenile with four weapons-related offenses, police said.