Dennis Alexander submitted his resignation to the Monterey Peninsula Unified School District on March 29. It will be effective at the end of the school year, district spokeswoman Marci McFadden told KSBW-TV.

Alexander last month was pointing the gun at the ceiling to make sure it was not loaded when the weapon discharged. No one sustained serious injuries but some students were hit by fallen ceiling debris, police said.

Alexander, who is a Seaside City Council member, was also a reserve Sand City police officer but he resigned that position after the incident.

Police officers “are obligated to handle firearms safely. They are not supposed to display firearms unnecessarily. You are not supposed to allow other people to handle your firearm,” said Sand City Police Chief Brian Ferrante.

While California has a state law banning teachers from bringing guns to school, Alexander was legally allowed to carry firearms on campus because he was a sworn peace officer.

Alexander has not responded to several requests for comment but he made an emotional apology during a city council meeting last month.

Many students in the coastal community about 115 miles (185 kilometers) south of San Francisco supported their well-liked teacher, organizing rallies and circulating a petition to keep Alexander at Seaside High School.

“We know Alexander's worth and meaning, that's what truly matters. He will always be a part of our Spartan family, no matter what,” student Cleve Waters told KSBW.