A former South Dakota high school principal is determined to help a former student who unexpectedly shot him in 2015. Two years and a confession later, former Principal Kevin Lein still sees a positive future ahead for gunman Mason Buhl.

In September 2015, Lein had a dangerous encounter with then-16-year-old Buhl. Lein planned on meeting with Buhl to discuss the student's grades. It was evident Buhl was struggling after transferring schools, something Lein wanted to help him with.

Before Lein had an opportunity to meet with Buhl, the student requested to go to the principal's office. Buhl walked into the office, unannounced, pointed a pistol at Lein's head and attempted to shoot the principal. At first, the gun malfunctioned but eventually, Buhl was able to fire a round, which grazed the principal's arm and chest, the Washington Post reported.

Buhl fled as Lein fell to the floor. The assistant principal and athletic director tackled the student, and he was arrested and taken into custody.

Lein was taken to the hospital and treated for flesh wounds but returned to the high school the next day, this time, with his arm in a sling.

On Wednesday, two years after the incident, the former student pled guilty to charges of attempted murder, the Argus Leader reported.

Officials at the state's psychiatric hospital examined Buhl and determined that mental health played a role in the shooting. However, the officials also ruled that Buhl was competent enough to stand trial as long as he had legal assistance.

Buhl, now 19, had his 25-year prison sentence suspended. Instead, the judge gave him 15 years probation.

Buhl will be committed to a mental hospital and will not face prison time as long as he meets the conditions of his probation, the Argus Leader reported.

"If you exhibit any, any, violent behavior once so ever I will be quick from any judgment to remove you from society," the judge told Buhl.

"I intend to show with my actions that I wish that never happened, that I'm not my mistakes, that I'm sorry to the community, Lincoln County and everyone involved," Buhl told the court, according to the Argus Leader.

Lein, who resigned as principal in April, pushed heavily for rehabilitation, not punishment, which was a major factor in the judge's decision.

“Forgiveness is really the only thing we control,” Lein, who is Catholic, told the Post.

The former principal said he plans to visit Buhl at the rehab facility.

"This was a tragic case for many reasons, but the outcome is just. The undisputed expert testimony, and testimony of those involved in Mason’s treatment supports Judge [Brad] Zell's decision," Buhl's attorney Michael Butler said in a statement. "Dr. Lein’s compassion and understanding is no small factor as well in giving Mason a second chance. Dr. Lein is an extraordinary man by any measure."