CANTON, S.D. (AP) — A South Dakota teenager accused of shooting and injuring his high school principal nearly two years ago has pleaded guilty to attempted murder.

A judge on Wednesday suspended all 25 years of Mason Buhl's sentence, with Buhl to serve 15 years on supervised probation. He will be committed to a mental health treatment program.

Authorities say Buhl brought a gun to Harrisburg High School on Sept. 30, 2015, and shot Principal Kevin Lein in the right arm. Buhl was tackled and restrained by two other high school staff members. No one else was hurt.

Buhl is now 18. He was charged as an adult with attempted murder and the commission of a felony while armed with a firearm.

Lincoln County State's Attorney Tom Wollman said earlier that Buhl was found competent to stand trial.