FREEPORT, Maine — The Freeport Middle School teacher charged with terrorizing in February after making a violent gun remark in front of his class pleaded no contest in Cumberland County Unified Court on Monday.

The complaint alleges David Mason, 59, of Yarmouth made a threatening comment in front of his seventh-grade class about firing an assault rifle from the roof of the school while people were present.

“It was a stupid thing to say and wasn’t meant to do harm,” Mason’s attorney, John Richardson, said Tuesday. “He did it to get their attention.”

Mason will have the charges dismissed if he is not involved in any criminal activity for 60 days, said Tamara Getchell, business and communications director for the Cumberland County district attorney’s office.

The terrorizing charge is a Class D misdemeanor and can carry a maximum year in jail and up to a $2,000 fine.

Mason, who has been teaching for 30 years, has not returned to teaching since the incident. He was placed on paid leave initially and more recently has been writing curriculum out of the district office, Richardson said.

Barring a conviction, Mason has no legal barriers keeping him from teaching in the future, Richardson said.