BRIGHTON, Colo. (CBS4)– The man charged with the shooting deaths of three people inside a crowded Walmart in Thornton last fall has pleaded guilty in the case.

Scott Ostrem, 48, was found mentally competent to stand trial earlier this summer. Last month, the judge entered a plea of not guilty on his behalf and set the case for trial.

That all changed on Wednesday when Ostrem agreed to plead guilty to three counts of first-degree murder to avoid the possibility of the death penalty.

Scott Ostrem (credit: CBS)

He is accused of killing Pamela Marques, 52, of Denver, Carlos Moreno, 66, of Thornton, and Victor Vasquez, 26, of Denver.

(credit: CBS)

Ostrem was charged with with 37 counts, including three counts of first-degree murder, three counts of first-degree murder extreme indifference and 30 counts attempted first-degree murder.

Victor Vasquez, Pamela Marques and Carlos Moreno

He will be sentenced to life in prison without parole on Oct. 19 in Adams County Court.