MONTERREY, Mexico – A 15-year-old student opened fire with a gun at a private school in the northern Mexican city of Monterrey on Wednesday, hitting a teacher and two other students in the head before killing himself.

Another student suffered lesser injuries in the shootings, which were captured on a chilling video posted to social media.

Nuevo Leon state Gov. Jaime Rodriguez said the shooter died at a hospital and that the other three victims with head wounds were “fighting between life and death.” The boy wounded in the arm was out of danger.

READ MORE: Baby shower shooting in Mexico City leaves man, 2 children dead

A video, apparently from the school’s surveillance camera, shows a female teacher handing out materials and students seated at their desks when a boy opens fire with a pistol from a sitting position, hitting a boy sitting in front of him, who immediately slumps to the ground.

Story continues below advertisement

He next shoots the teacher, who was looking in another direction, and she falls to the ground. The boy rises from his seat and walks around, firing shots at his classmates, before turning the gun on himself.

His first shot apparently misses his head, and then he runs out of bullets. The shooter runs to his backpack, apparently to reload, as his classmates cower at their desks. He appears to say something to the surviving students, who begin to rush for the door, and then he shoots himself in the head and falls to the ground.

The crowded classroom was left with a jumble of overturned chairs, blood and fallen students.

State security spokesman Aldo Fasci said four of the injured, including the shooter himself, had bullet wounds to the head and were in extremely serious condition. He said the student shot the 24-year-old teacher, a 14-year-old girl and a 14-year-old boy in the head, and a 15-year-old classmate in the arm. He then pointed the gun at classmates before shooting himself in the head.

“The classes were going perfectly well, the student stands up from his desk and pulls out a gun,” Fasci said. Tweet This

He noted that photographs of the shooting had been posted to social media and said the person responsible would be punished. He also appealed to the news media to avoid using the images, which show minors.

Story continues below advertisement

WATCH: Montreal’s McGill University releases training video in case of school shooting

2:03 McGill releases training video in case of school shooting McGill releases training video in case of school shooting

Fasci said the shooter had been under treatment for depression, but that the motive was under investigation.

The spokesman attributed it to “the situation that is happening everywhere. The children have access to the internet. This has happened in other countries.”

The website of the American School of the Northeast says it offers bilingual education for students from preschool through ninth grade.

Fasci said the boy brought the gun from home. It was unclear how he got the .22 calibre pistol into the school. Mexico had once had a program to checked book bags at school entrances, but in many places it has fallen into disuse.

“‘There was a reason why book bags were checked. I think we are going to have to start doing it again,” Fasci said. Tweet This

Story continues below advertisement

Mexico had been largely spared the phenomenon of school shootings that has hit the United States. In one of the few previous incidents, a 13-year-old student shot a 12-year-old classmate in the head at a Mexico City middle school in 2004, seriously wounding her.

At the height of Mexico’s drug war between 2008 and 2011, schools in northern Mexico were more concerned about the possibility that stray bullets from drug gang gun battles outside schools might enter classrooms. Some schools conducted “duck and cover” drills to combat that possibility.