COLUMBUS, Ohio (AP) — The search of a high school student’s backpack that authorities say led to the discovery of bullets and later a gun was constitutional, the Ohio Supreme Court ruled Thursday.

At issue before the high court was whether the search of the backpack following an initial search violated the student’s privacy rights, which are generally weaker inside school walls.

A security official at Whetstone High School in Columbus searched the backpack in 2013 after it was found on a bus, according to court filings. The official conducted the second search after he recalled that the student had alleged gang ties, and found 13 bullets after dumping the bag’s contents, records show.

That search led to police being called and the discovery of a gun in another bag the student had, according to court records. The student, Joshua Polk, has been charged with possessing a deadly weapon in a school safety zone.

Justice Sharon Kennedy, writing for the court, said the school’s search policy furthers the “compelling governmental interest” in protecting public school students from harm.

In light of those rules, and because of the student’s lower expectation of privacy, “we conclude that Whetstone’s protocol requiring searches of unattended book bags to identify their owners and to ensure that their contents are not dangerous is reasonable under the Fourth Amendment,” Kennedy wrote.

Prosecutors in Franklin County had appealed after two lower courts tossed out the evidence against the student because of the second search. Thursday’s ruling means the evidence can now be used.

Polk’s attorneys argued the school went too far when the security officer conducted a fuller search simply because of rumors he recalled about Polk. Polk’s public defender declined to comment Thursday.

Prosecutors argued that Polk, who was 18 at the time, gave up his privacy rights when the bag was left on a school bus.

Six school associations representing school boards, administrators, teachers and others sided with prosecutors to argue that the search was justified.

Polk was backed by 15 youth law groups around the country who urged the Supreme Court not to overturn the lower court rulings. They say the increased presence of security officers in schools nationally is creating a culture that refers thousands of students to police each year, raising concerns about their constitutional rights.