MINNEAPOLIS — A Minnesota man confessed Tuesday to abducting and killing 11-year-old Jacob Wetterling nearly 27 years ago, recounting a crime that long haunted the state in chilling detail that included a handcuffed Jacob asking him, “What did I do wrong?”

Danny Heinrich, 53, of Annandale, made the admission as he pleaded guilty to a federal child pornography charge that will likely keep him locked up for 20 years, with civil commitment possible after that, meaning he could spend the rest of his life in custody. Asked whether he abducted, sexually assaulted and murdered Jacob, Heinrich said: “Yes, I did.”

As part of the plea agreement, Heinrich will not face state murder charges in Jacob’s death. U.S. Attorney Andy Luger said it was the only way to get Heinrich, whom he described as a volatile man, to show authorities where they could find the boy’s remains.

“He’s not getting away with anything. We got the truth. The Wetterling family will bring him home,” Luger said.

Prosecutors said the family was consulted on and approved the plea agreement, which required Heinrich to give a detailed confession and tell investigators where to find Jacob.

In the years after Jacob’s disappearance, his mother, Patty, became a nationally known advocate for missing children. A 1994 federal law named for Jacob requires states to establish sex offender registries.

With Patty and Jacob’s father, Jerry Wetterling, in a packed courtroom, Heinrich described seeing Jacob, Jacob’s brother, and a friend bicycling down a rural road near Jacob’s central Minnesota home in St. Joseph the night of Oct. 22, 1989.

Heinrich laid in wait for the three boys to return, and when they did, he put on a mask and confronted them with a revolver.

Heinrich said he told the two other boys to run and not look back or he’d shoot. He said he then handcuffed Jacob and drove him to a gravel pit near Paynesville, where he molested him. Afterward, Jacob said he was cold, and Heinrich let him get dressed. Jacob then asked whether he was taking him home. “I said, ‘I can’t take you all the way home,”‘ Heinrich said.

Heinrich said at some point a patrol car with siren and lights passing nearby caused him to panic. He said he pulled out his revolver, which had not been loaded, and put two rounds in the gun. He said he told Jacob to turn around. He held the gun to the boy’s head and pulled the trigger. The gun didn’t fire. Heinrich then fired two shots. After the second, Jacob fell to the ground.

Some of Jacob’s family members cried openly as Heinrich calmly described the crime.

Heinrich said he went home for a couple of hours, then went back to the gravel pit and buried Jacob about 100 yards away. He said he returned to the site about a year later and saw that Jacob’s jacket and some bones had become exposed.

“I gathered up as much as I could and put it in the bag and transported it across the highway” to a field, and reburied the remains, he said.

Heinrich led authorities to Jacob’s buried remains in a central Minnesota field last week. The remains were identified Saturday.