The gym teacher arrested and charged with burglary after police discovered him sleeping in a locker room at the school where he worked had his case dismissed in district court Friday.

Police arrested Benjamin Morey, a physical education teacher working at Redland Middle School in Rockville, on Feb. 15. He was placed on administrative leave and is now working at a different school.

Police had charged Morey, 35, of Hyacinth Court in Gaithersburg, with unlawful trespassing, burglary, and resisting arrest after they discovered him in the school at 2:30 a.m., asleep on a pile of mats in one of the locker rooms, according to his charging documents.

After the dismissal, Morey’s lawyer, Stephen Galfond, said Morey “was glad [the prosecution] did the right thing.”

“Upon further review of the facts in the case and based on the fact that the defendant was allowed to be at the school, it was determined to be in the best interest of all parties to refrain from pursuing a prosecution of this matter,” Montgomery County State’s Attorney’s Office spokesman Ramon Korionoff said of the case.

Morey declined to comment about the proceedings.

Galfond said that since Morey had worked at the school, he had not met the definition of the class of person excluded from the building.

About the burglary charge, Galfond said Morey had been given keys to the school.

“He was not there for any unlawful purpose,” he said.

Galfond said Morey had “suffered enough after being mauled by a dog.”

In the course of being arrested, Morey was punched in the face and ribs and attacked by a police dog.

As to why Morey was found asleep in the locker room, Galfond said, “He had school that morning and had planned to sleep there until his duty day started.” Galfond declined to comment further on why Morey was sleeping there that specific morning, when he had school most mornings.

Montgomery County Public Schools spokesman Dana Tofig said Morey began working at White Oak Middle School last month. Tofig declined to talk about specifics of Morey’s case.

“In general, an employee is placed on leave pending an investigation by the school system. What happens after that depends on the findings of the investigation,” he wrote in an e-mail.