DANVERS, Mass. — On the morning of Oct. 22, Philip Chism, a 14-year-old student and soccer player, took a ski mask, gloves, multiple changes of clothes and a box-cutter with him to school, according to the police.

Chism was later seen in surveillance videos from cameras at Danvers High School putting on the gloves and pulling the hood of a sweatshirt over his head as he followed his math teacher, Colleen Ritzer, 24, into a school bathroom, the police said in court papers released Friday.

Shortly thereafter, the video showed him rolling a recycling bin into the bathroom and leaving, this time wearing a white T-shirt and a black mask.

By the end of the day Ritzer had been raped, and stabbed multiple times. Her throat was slit. Her body had been dumped into nearby woods; next to it was a folded, handwritten note saying, “I hate you all.”

Chism has been indicted on charges of murder, aggravated rape and armed robbery. He is to be arraigned in Essex Superior Court on Dec. 4.

The court papers provide a timeline and details of a gruesome crime that has shaken this quiet suburb, about 20 miles north of Boston. And they offer a few clues about Chism's life: his parents had been undergoing what his mother called a “stressful” divorce, for example.

But they do not address the central question of why a young man like Chism, who apparently showed no outward signs of trouble or aggression, might have mutilated, raped and murdered his teacher, who was beloved by most of her students and went out of her way to help them.

Dr. Eugene Beresin, a professor of psychiatry at Harvard Medical School and a specialist in adolescent psychiatry at the Clay Center at Massachusetts General Hospital, said such cases were “off-the-charts rare.”

“I personally have never seen anything like this in the hundreds of cases I've had and the thousands of cases I've supervised,” he said.

He has not been involved in the case and is not privy to any information that might help connect the dots here, and he said it was hard for him to make any sense of it.

“Most kids who commit violent acts have a history, a history of something, of impulsivity, of mood disorders, or of abuse and neglect,” Beresin said. “I see kids every day who have witnessed the most horrifying sexual and physical abuse, for example, or have been abused themselves, but they don't do this.”

Any number of internal factors, such as a percolating psychosis or a neurological condition, or external factors, such as abuse, could be involved, he said.

It is also possible, he added, that a motive may never be discerned.

Robert C. LaBarge Jr., a state trooper, wrote in the court papers released Friday that he believed Chism “planned the crime” because he went to school “armed with a box-cutter, a balaclava/ski mask, gloves” and several changes of clothes.

Chism was a student in Ritzer's last-period class that day. An unidentified student told the police that after class, she was in Ritzer's classroom and saw the teacher and Chism there talking about China.

The student said Ritzer then mentioned Tennessee, the state Chism left a few months before with his mother, and that Chism “became visibly upset.” She said that at first, Ritzer did not seem aware that Chism was upset but then realized he was and changed the subject.

The unidentified student also said “she observed Philip apparently talking to himself in the classroom,” the court papers said.

The video cameras — now a staple in newly built schools like this one — showed Ritzer walking out of her classroom and down a hallway toward a women's bathroom at 2:54 p.m. At the same time, Chism walked into the hallway, then ducked back into the classroom. He then emerged from the classroom with a hood over his head and went into the same bathroom, pulling on the gloves.

At 3:07, he left the bathroom with a hood over his head. He went outside to the student parking lot and came back in the building at 3:09 wearing a white T-shirt. He went back to the classroom and emerged at 3:11 with a red hooded sweatshirt over his head and returned at 3:16 with a recycling bin. At 3:22, he emerged in a white T-shirt and a black mask, pulling the bin and heading toward an elevator and then outside.

Video picked him up coming back into the school at 4:00. By 4:04 he was seen wearing a black shirt and glasses and carrying a pair of jeans. A minute later he went back to the original bathroom, then left the school a minute after that.

After the police were notified that both student and teacher were missing, they conducted a search.

At 12:30 the next morning, the police found Chism walking on a nearby highway. He had a knife and a bloodstained box-cutter, they said. Asked where the blood came from, Chism said, “The girl,” according to the court papers. They also found Ritzer's credit cards, driver's license and underwear in his backpack, they said, then placed him under arrest and charged him with murder, to which he later pleaded not guilty.

At that point, the police went to look for her body. They found it, half-naked, near the school, covered with leaves and debris. A recycling bin was nearby, as were blood-soaked gloves.

LaBarge wrote that he was seeking warrants to search Chism's basement apartment, where he lived with his mother and two sisters, and his computers. He said that based on prior experience, he knew that people involved in violent crimes “often will have an obsession and this obsession can include Internet searches for their victims and sexual-fetish-based Internet inquiries.”

He also said he expected to find “documents describing planning the crime, the defendant's mental status, and any nexus for the reason the defendant expressed his hate for everyone as described in the note found adjacent to the victim's body.”