Law enforcement officials swarmed Falmouth High School Thursday with the help of police K-9 units as part of a "lockdown" drill performed twice a year, the Cape Cod Times reported.
One of the dogs reacted to a student's backpack, police said, and 18-year-old Matthew Montella was taken to the principal's office by officers and school officials.
The backpack contained a package of marijuana brownies Montella allegedly admitted to making, police said.
A search of Montella's car that also attracted the attention of a police dog found four trays of similar brownies in the trunk.
Police said Montella admitted to selling the brownies for $10 each during school hours.
Montella was arraigned Thursday and pleaded not guilty to distribution of marijuana and a drug violation near a school.
The lockdown drills and K-9 inspections have been taking place for the past four years and are meant to prepare students and staff for an emergency situation such as a school shooting, Falmouth schools Superintendent Marc Dupuis said.
Notable deaths of 2014 [PHOTOS]