SALEM, Massachusetts — A Massachusetts prosecutor on Monday described a 16-year-old former high school student charged with murdering his math teacher as a remorseless killer, while his attorney portrayed the teen as mentally disturbed and not in control of his actions.

Philip Chism, 16, is being tried as an adult in the murder of Colleen Ritzer, who had been a popular 24-year-old teacher at his high school in Danvers, Massachusetts, a town of 26,000 people about 20 miles north of Boston.

“The defendant arrived at Danvers High School with a mask, a boxcutter and a terrible purpose,” Kate McDougall, an Essex County prosecutor, said.

Chism’s attorney said the teen, a 14-year-old freshman at the time of the attack, attacked Ritzer Oct. 22, 2013, due to mental illness.

“Why did a 14-year-old boy, well behaved, quiet, one month into high school, do these terrible things?” defense attorney Denise Regan said. “The answer is he was severely mentally ill. He was suffering from psychotic disorder since age 10.”

That day, prosecutors contend, Chism followed Ritzer into the bathroom after school, raped her, cut her throat with a box cutter and transported her body off campus in a recycling receptacle. Ritzer’s body was found in woods near Danvers High School with a note reading: “I hate you all.”

Chism also is accused of taking Ritzer’s credit card, which prosecutors say he later used to buy fast food and a ticket to a movie at a nearby mall.

Chism is being charged as an adult under Massachusetts law for first-degree murder. He has also been charged as a juvenile for two counts of aggravated rape and armed robbery.

If found guilty of first-degree murder, he would face a mandatory sentence of life in prison without the possibility of parole.

Chism, who was known as quiet and a talented soccer player, was described at the time as being under emotional strain after relocating to Danvers from Tennessee with his mother following his parents’ divorce.