A Colorado man pleaded guilty on Friday to killing a female friend of his ex-girlfriend and was ordered to spend the rest of his life in prison.

Danny M. Gallegos, 33, pleaded guilty to shooting Tammy Snydergaard, 18, of Sandy, point-blank in the back of the head during a bizarre shooting spree at his ex-girlfriend's South Salt Lake apartment on March 11, 1990.Prosecutors agreed not to ask for the death penalty in exchange for his guilty plea to capital homicide. Third District Judge Michael Murphy deliberated for more than two hours before Friday before deciding Gallegos should receive a life sentence instead of execution.

The judge also ordered Gallegos to pay an unspecified amount of restitution to the victim's family.

Gallegos apologized to Snydergaard's family and his family and said he wished there was a word other than "sorry" to better convey his feelings of regret for what he did.

"Making a mistake in life is not the worst thing that can happen, but not learning from that is worse," he said. "I pray that Jehovah will have mercy on all of us in the end for the mistakes we have done and the errors we have made."

Defense attorney Gilbert Athay said a psychiatrist at the University of Utah examined Gallegos and determined that he has a mental illness. "The murder was committed while the defendant was under the influence of extreme mental or emotional disturbance," he said.

Gallegos' mother died when he was 3 years old and he was also traumatized by physical abuse by his father. "Danny never recovered from the loss of his mother," Athay said. "Violence is what he was taught from the age of 3 until he left home."

Gallegos' wife was killed during an accident in which she fell off of a building while washing windows, Athay said. He later met Stephanie Groves. But when she tried to break off their relationship, he saw that as another abandonment similar to the deaths of his mother and wife. His rage during the shooting was a re-enactment of the cruelty he learned from his father, Athay said.

"The mental illness was one of the reasons he did what he did."

During a preliminary hearing last summer, witnesses testified that Gallegos was hiding in a closet in Groves' apartment when he jumped out, pointed a gun at Snydergaard, Groves and James Esquibel and said, "I got you now!"

Esquibel and Groves fled to a bedroom. "He said, `Let me in, I'm going to (expletive) kill you,' " Esquibel testified. Gallegos then fired a gun through the closed door and hit Groves in the chest.

Esquibel later subdued the defendant, but he then jumped out of a bedroom window. When the other two returned to the living room, they discovered Snydergaard lying on the floor with a gunshot wound to the head, they testified.

Gallegos was also charged with kidnapping and sexually assaulting Groves the month before. Those charges and attempted first-degree murder charges were dropped as part of a plea bargain with prosecutors.

Deputy Salt Lake County Attorney Glen Iwasaki said he spoke with the two survivors and members of the victim's family and they all approved of the plea arrangement. Even if the case had gone to trial, Gallegos may not have been sentenced to die.