SANTA CLARITA, Calif. (AP) — A student pulled a gun from his backpack and opened fire at a Southern California high school Thursday, killing two students and wounding three others before shooting himself in the head on his 16th birthday, authorities said.

The attacker was hospitalized in critical condition, officials said.

The gunfire began around 7:30 a.m. at Saugus High School in suburban Santa Clarita, where Los Angeles County sheriff’s deputies responding to a torrent of 911 calls found all six students in a quad area.

Security video showed the last thing the attacker did was shoot himself with the final bullet in the .45-caliber handgun, sheriff’s homicide Capt. Kent Wegener said.

The attack lasted about 16 seconds, and the attacker apparently fired at random because he had no known connection to the victims, Wegener told a news conference. The motive remained unclear.

A 16-year-old girl and a 14-year-old boy died.

Two girls, ages 14 and 15, were each in good condition after being treated for gunshot wounds, according to Patricia Aidem, a spokeswoman for Providence Holy Cross Medical Center.

A 14-year-old boy was treated and released from another hospital, authorities said.

Sheriff Alex Villanueva said the shooter was a student at the school but did not identify him.

The sheriff said a biography on an Instagram account believed to belong to the teen contained the posting: “Saugus, have fun at school tomorrow.”

The message was discovered Thursday morning after the shooting. It was unclear when it was made and by whom, the sheriff said.

It was later removed, and investigators do not know who made the change, Wegener said.

Investigators were searching the suspect’s home. Wegener said the sheriff's department had not received any recent calls to the boy's house "that would indicate that there was turmoil" there.

"At this point in time, we have no indication of motivation or ideology,” said Paul Delacourt, the agent in charge of the FBI’s Los Angeles field office. Santa Clarita is a city of more than 200,000 about 30 miles (48 kilometers) northwest of downtown LA.

The sound of gunfire sent some students running while others and staff followed recently practiced security procedures.

Kyra Stapp, 17, was watching a documentary in class when she heard two gunshots. Panicked students ran in and reported the shooting.

Stapp’s class and others were herded into a teacher break room where they locked the door and turned off the lights.

Kyra texted her mother and tried not make any noise. They exchanged messages as sirens screamed and helicopters and deputies carrying rifles and shotguns swarmed the campus. Then Kyra fell silent while officers escorted students out.

“She’s been texting me and all of a sudden she’s not,” Tracy Stapp said. “That was like the worst 10 minutes of my life, I swear.”

Shauna Orandi, 16, said she was in her Spanish class doing homework when she heard four gunshots that she initially mistook as instruments from a band class. She said a student burst into the room saying he’d seen the gunman, and her classmates were stunned into silence.

“My worst nightmare actually came true,” she said later as she left a nearby park with her father. “This is it. I’m gonna die.”

Freshman Rosie Rodriguez said she was walking up the library stairs when she heard noises that “sounded like balloons” popping. She realized they were gunshots when she saw other students running.

Still carrying a backpack laden with books, she ran across the street to a home, where a person she didn’t know gave shelter to her and about 10 other students.

“I just heard a lot of kids crying. We were scared,” Rodriguez said.

A huge crowd of anxious parents gathered in the park, waiting to be reunited with their children.

Undersheriff Tim Murakami tweeted an apology to the parents, saying investigators needed to interview the students before they could be released.

Orandi said she has heard about so many school shootings that she always assumed she’d panic. But she stayed calm with the help of her teacher, who locked down the classroom.

Saugus High’s security is provided by one unarmed sheriff’s deputy and nine “campus supervisors” who act as guards, said to Collyn Nielson, chief administrative officer for the William S. Hart Union High School District.

The campus is surrounded by a fence, and students enter through a limited number of gates each morning. There are a dozen security cameras but no metal detectors.

All district schools hold lockdown drills three times a year, including two in the fall that have already occurred, Nielson said.

“In speaking with staff and hearing reports, students reported they knew what to do and immediately went into lockdown mode,” he said.

Antczak reported from Los Angeles. Associated Press writers Christopher Weber, Brian Melley and Justin Pritchard in LA also contributed to this report.