The lockdown at McKittrick School has been lifted, the Kern County Sheriff's Office reported about 2 p.m.
Kern County Sheriff's deputies have detained a possible suspect, a spokesman said.
McKittrick school was placed on lockdown for about 40 minutes after deputies were dispatched to a report of a man with a rifle near apartments at Highway 33 and E Street.
The suspect was apparently seen by witnesses near the apartments behind a market.
When they arrived, a suspect ran from deputies and the school was placed on lockdown about 1:20 p.m.
As more deputies arrived, a perimeter was set up and the search began.