Newly released surveillance video shows the moment an Oregon school coach disarmed and hugged a shotgun-wielding student, averting a potential tragedy.

Angel Granados-Diaz, 19, is seen on the video walking into the fine arts building of Parkrose High School in Portland with a shotgun hidden under his jacket on May 17, 2019.

Officials said Granados-Diaz was experiencing a mental health crisis when he brought the gun containing one round to school.

Angel Granados Dias Portland police dept.

Keanon Lowe, a former star wide receiver for the University of Oregon Ducks who works at Parkrose High as a security guard and football and track-and-field coach, said he saw something in Granados-Diaz's face, "the look in his eyes. I looked at the gun and I realized it was a real gun and then my instincts just took over."

Students are seen in the video running away as Lowe takes the gun from Granados-Diaz. After handing the gun off to another teacher, Lowe grabs Granados-Diaz into a hug.

“I just wanted to let him know that I was there for him. I told him I was there to save him. I was there for a reason and that this is a life worth living,” Lowe said afterward.

Keanon Lowe, a former analyst for the 49ers and wide receiver at the University of Oregon, subdued a person with a gun who appeared on a Portland, Oregon high school campus on May 17, 2019. AP file

“The universe works in amazing ways. I’m lucky and I’m happy that I was in that classroom for all those kids and I was able to prevent that tragedy," he said.

Later, police are shown arriving at the school and taking Granados-Diaz into custody. No one at the school was injured.

Granados-Diaz has remained in custody since he was arrested in May. Last week, he pleaded guilty to two charges related to having a loaded gun in a public place.

A judge sentenced him to 36 months of probation, as well as immediate mental health and substance abuse treatment.

Multnomah County Deputy District Attorney Parakram Singh said, “Through the course of the investigation it became clear to law enforcement and our office that Mr. Granados-Diaz did not have the intent to hurt anyone other than himself while at Parkrose High School,” NBC afiliate KGW reported.

The resolution of the case helps Granados-Diaz address his suicidal ideations and ensures a level of accountability for taking a loaded gun to school, Singh added.