HARRISBURG (AP) - A former South Dakota high school student who shot his principal two years ago has pleaded guilty to attempted murder.

Mason Buhl, 18, pleaded Wednesday at the Lincoln County Courthouse in Canton. He'll be committed to a mental health treatment program as long as he meets conditions of his probation, the Argus Leader reported.

Newsletter signup for email alerts

"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 said.

Judge Brad Zell suspended all 25 years of Buhl's sentence because of his mental health and the belief among attorneys that Buhl can be rehabilitated.

"If you exhibit any, any violent behavior whatsoever, I will be quick from any judgment to remove you from society," Zell told Buhl.

Authorities said Buhl was 16 when he brought a gun to Harrisburg High School in September 2015 and shot then-Principal Kevin Lein in the right arm. Buhl was allegedly carrying more than 50 bullets that day, but his firearm malfunctioned. Two other school officials tackled and restrained him.

Lein, now a central Iowa school administrator, said he thinks Buhl was a "victim of circumstances" and wished he interacted more with Buhl before the shooting.

"I don't even think, for him, it was necessarily me he was attacking," Lein said. "He was attacking the fact that he wasn't getting help."

Lein hopes there's a positive outcome for Buhl, who sat in jail for nearly two years until the verdict. He also said there needs to be more progress in addressing the mental health needs of teenagers.

"Most people are pretty black and white about this. He did something, and he should receive punishment. I'm not that way. I can tell you for sure in that moment Mason wasn't thinking about punishment," Lein said. "I don't believe in evil. I believe in the good of everybody, and maybe I saw (evil) that day, but I think it was imprinted on him. I don't think he's an evil person."

Lein said he plans to visit Buhl in prison after his sentencing to find out what he can do to help the teen "get a good future."