An Oak Park Heights prison inmate pleaded guilty Thursday to strangling a fellow prisoner after discovering the man was serving time for molesting a child.

Benjamin Heath Beck, 40, was given a 40-year sentence for killing Shane Lawrence Cooper, 30, of Superior, Wis., in December. They were friends until Beck learned why Cooper was sent to prison.

“The victim was serving his time. He thought he had a friend and the friend betrayed him,” Washington County prosecutor Tom Wedes said of Beck’s violent choking of Cooper with a shoelace.

Beck was seen on video surveillance entering Cooper’s cell, and his prison identification was found near the body, according to a criminal complaint filed in Washington County District Court.

“It is senseless, it hurts,” Cooper’s father, Lance, told the Stillwater court before District Judge John McBride sentenced Beck. “I’ll never hear my boy laugh ever again. I hope you rot in hell.”

Beck described himself to investigators as Cooper’s “protector” after Cooper entered the prison in 2012, although the complaint didn’t explain what Beck meant by that.

The complaint said that when Beck “found out why [Cooper] was incarcerated, defendant indicated to the agents that he could no longer be a protector of someone who had committed this type of crime and that victim did not give him a way out.”

Beck told investigators that he used a shoelace from a tennis shoe in his cell. He fashioned handles and “admitted that he did not believe that [the] victim knew what was coming,” the complaint said.

He also said that he knew when corrections officers would do a “room check” and timed the assault accordingly.

Beck was serving a 57-month sentence for first-degree aggravated robbery and first-degree burglary in Fillmore County. Thursday’s sentence for second-degree murder will run consecutively with Beck’s other convictions, including forthcoming prison time in Oklahoma for possession of a stolen vehicle and escape from confinement.

The murder was the first inside the maximum-security prison since it opened in 1982.

Beck declined to make a statement about his crime to the court Thursday, although he spoke in respectful tones to attorneys and the judge when questioned about his plea. His public defender, Betsy Schollmeier, said he asked her to express his sympathies to Cooper’s parents for killing their son.

“He knew what he was facing, accepted it, and he’s ready to move forward with the consequences,” she said after the sentencing.

McBride, however, lectured Beck from the bench for killing Cooper and said the consecutive sentence would ensure that Beck never again walks as a free man.

“You took his life without any mercy at all,” McBride told Beck. “It’s about as cold and calculated as any I have seen.”