(CNN) The 16-year-old gunman who shot himself after killing two classmates and wounding three other students in Southern California has died at a hospital, authorities said.

The junior at Saugus High School in Santa Clarita died Friday afternoon, the Los Angeles County Sheriff's Department said.

The teen opened fire at the school Thursday -- his birthday — and used his last bullet to shoot himself in the head. His motive remains a mystery.

"There's nothing really that stands out (with the suspect). He wasn't a loner. Wasn't socially awkward. Was involved in student activities. Student athlete," Los Angeles County Sheriff Alex Villanueva told CNN's New Day. "This is kind of out of the blue, shocking pretty much everyone who knew him."

Investigators are digging into the suspect's social media and background, he said. He was identified as Nathaniel Berhow, and he lived with his mother, who was with him when he died. His father died in 2017 of natural causes.

There appears to be no connection between the shooter and the victims other than all were students, the sheriff said.

"He wasn't chasing anyone," Villanueva said. The victims "appeared to be who was around him, available at the time."

Students followed their active shooter training

After the gunshots began, and five students were hit, training kicked in for thousands of pupils stunned that gun violence they had once protested had invaded their Southern California campus.

Grace Anne Muehlberger, 15, was one of two students killed in the Saugus High School shooting.

"Kudos to all of them for a job well done and, hopefully, that's a job we never have to do again," Villanueva said Friday.

The sheriff said Saugus High School had an active shooter drill just a few weeks ago. The students on Thursday did exactly as they were trained, he said.

Authorities said that shortly before school was to begin at the school, the shooter walked into a campus area known as the quad, took a .45-caliber pistol from his backpack and shot the people near him before shooting himself.

Two students, Grace Anne Muehlberger, 15, and Dominic Blackwell, 14, died at a hospital. Three other teens were wounded and are expected to survive.

Detective dropping off child was first to aid victims

Training kicked in for three off-duty law enforcement officers and the school resource deputy who was just arriving at the school of 2,400 students.

An off-duty detective was dropping off his girlfriend's son at Saugus High School when he saw hundreds of students running from the campus Thursday morning. He pulled in and asked a student what was going on.

Someone was shooting, Detective Daniel Finn was told. Finn rushed from his car to the scene where unbeknownst to him six people had been shot, two fatally.

He and another off-duty officer found two of the five victims and the shooter still on the ground of a campus area known as the quad. Finn said he saw the shooter's gun but wasn't aware one of the people being treated was the gunman.

"My main concern then was securing the scene, treating the victims, and trying to make sure there wasn't an additional shooter," Finn told reporters Friday.

Finn, a former school resource deputy now with the Los Angeles County Sheriff's Department, told an administrator to grab medical aid bags from the school office. A third off-duty officer and the current school resource officer assisted him in treating the victims until medical help arrived.

The weapon apparently jammed, sheriff says

Students are comforted as they wait to be reunited with their parents following the shooting at Saugus High School.

The shooter pulled out the large-caliber pistol without saying a word and fired one round, Villanueva said.

After shooting one student, he cleared a jam on the weapon and fired an additional four bullets at others, then himself.

"That ended it all in 16 seconds," the sheriff added.

Though it was not immediately known where the shooter got the gun, he seemed to have fired this pistol before, the sheriff said.

The suspect cleared the malfunction quickly, Villanueva said, discussing surveillance video from the high school that showed the attack.

His father had been a hunter and possessed firearms, and there were other firearms found in his home, Villanueva said.

"The six firearms (recovered from the home) were firearms that were registered from the deceased father," Villanueva said. "We've accounted for all six and they do not match the weapon recovered (at the school) so that is an ongoing part of the investigation, the origin of the weapon."