A 17-year-old student at Magruder High School in Rockville was arrested and charged as an adult with weapons offenses on school grounds Thursday morning, police said.

Montgomery County Police said Thursday that Octavio Antonio Estevez, of Southeast Washington, was charged with possession of a weapon on school property and other offenses after an incident shortly before 8 a.m., in which a school resource officer spotted him and noted that he was not supposed to be on school property.

When the officer asked Estevez to leave, police said, he refused and was arrested for trespassing.

An unloaded .22 caliber handgun was found after a search of Estevez’s backpack, police said. The gun was described as “older,” and it was unclear whether it still worked.