As a teen gunman opened fire at a Southern California high school on Thursday, a terrified classmate texted her mom a heartbreaking message to thank her and say she loved her, a report said.

Cari Wright said her daughter texted her as the teen hid in Saugus High School’s music library amid the gunfire, ABC Los Angeles reported.

“Hey mom i don’t know whats going on here at school but i love you and im so thankful for everything youve done for me. i love you so much,” the girl texted her mother, who showed the messages to the news station.

“Everyone is saying theres a shooter on campus i dont know whats going on but i love you and dad so much,” the student added.

“I love you baby. Stay safe,” Wright texted her daughter back.

Wright was later reunited with both of her daughters who were at the school — but not injured — at the time of the shooting, she told the station.

The 16-year-old gunman — identified as Nathaniel Berhow — allegedly stormed into Saugus High School just before classes began Thursday, killed two students and injured at least three others with a .45-caliber semi-automatic pistol before turning the gun on himself, police said.

Berhow survived the self-inflicted gunshot wound to his head and is currently in “grave condition,” authorities said.