The student, 16, was booked into juvenile hall in San Bernardino on charges of possessing a firearm on school grounds and being a minor in possession of a firearm, district spokeswoman Linda Bardere said Friday.
"It was during class and the CSO was doing his rounds, wondering what these two boys were doing in the bathroom," Bardere said. "He found one young man to be in possession of a backpack, and upon searching it he found the gun."
The other student was disciplined for skipping class, she said.
School police don't think the student intended to use the gun, she said, but they're not sure why he brought it.
"There's no indication that the weapon was taken out of the backpack or anything like that," she said.
The incident was at 11:10 a.m., one day after another San Bernardino High student was found with an airsoft BB gun, but Bardere said police didn't think there was a connection. She didn't have information on how many weapons have been found at the school this year and whether there was an increase.
The San Bernardino City Unified School District's new safety task force, formed in response to the killing of 26 people at Sandyhook Elementary School in Connecticut, will first meet Feb. 28, Bardere said.