Finally, Minnesota knows.

The question haunting a family and a state for nearly 27 years — what happened to Jacob Wetterling — was solved Tuesday when his murderer stood in federal court and recounted in horrific detail how he kidnapped the sandy-haired boy on a dead-end rural road, drove him into the dark countryside and sexually assaulted, then executed him.

"What did I do wrong?" Jacob asked his kidnapper, Danny Heinrich, after Heinrich snatched the boy at gunpoint and sent Jacob's little brother and best friend running away scared.

The answers came after federal prosecutors cut a deal with Heinrich, who after years of denying involvement in Wetterling's disappearance led authorities to the boy's shallow grave in a rural pasture outside the central Minnesota town of Paynesville, some 30 miles from the site of the abduction that brought excruciating pain to the Wetterling family and nightmares to parents across the state.

Heinrich, 53, pleaded guilty to one count of receiving child pornography, a crime for which he is expected to spend 20 years behind bars. Though he will not be prosecuted for Jacob's kidnapping and murder, Heinrich could remain in state custody under Minnesota's civil sex offender commitment.

The unusual deal was struck, officials said, with the approval of Patty and Jerry Wetterling, who have advocated nationally for missing and exploited children while keeping hope that somehow their son would be found alive.

"I want to say 'Jacob, I'm so sorry.' It's incredibly painful to know his … last hours, last minutes," Patty Wetterling said, fighting tears as she spoke to reporters after Heinrich's plea hearing. "Our hearts are hurting. For us, Jacob was alive until we found him."

Exchanging a possible murder prosecution for a single child pornography charge — one of 25 Heinrich was facing — was simply the only way to get the volatile Heinrich to lead authorities to the grave that no one had been able to find after almost three decades of intensive searching, U.S. Attorney Andrew Luger explained.

"He's not getting away with anything," Luger said. "We got the truth. The Wetterling family can bring [Jacob] home."

That October night

Standing in court, with Wetterling's parents sitting in the gallery behind him, Heinrich described Jacob's final hours in agonizing detail:

"I was driving on a road, a dead-end road. I noticed three children on their bicycles with a flashlight," Heinrich started, at times struggling to get his words out between sharp breaths.

After Heinrich and the boys passed each other that night, he said, he pulled his car into a driveway and faced the direction of the road that they'd be coming back on. Then he waited.

As the boys returned about 20 minutes later, Heinrich got out of his car and, with a mask on, reached for his revolver, a snub-nosed .38 Smith & Wesson Special.

He confronted the boys, told them to get into the ditch with their bicycles, then asked their names and ages.

The boys offered Heinrich the videotape that they had just rented from the convenience store, but Heinrich knocked it down. They shined their flashlight in his face, and he told them "no, don't do that," he testified.

He told Trevor Wetterling and Aaron Larson to run away, warning them not to look back or he'd shoot.

He took Jacob back to his car, handcuffed him behind his back and placed him in the passenger seat.

Heinrich then drove from St. Joseph with a police scanner crackling with activity inside the car. He told Jacob to duck down as he decided to drive back toward his hometown of Paynesville.

The car went on a circuitous route: west on Hwy. 75, then on Interstate 94, exiting at Albany and cruising onto another county road toward the town of Roscoe before hitting Hwy. 23 to Paynesville.

On the outskirts of town, Heinrich pulled the car onto a country road that he knew well, one with a field approach about 100 yards ahead. Next to a row of trees, not far from a gravel pit, Heinrich opened Jacob's door and uncuffed him. He took him near the trees, where they both undressed. Heinrich groped the boy and forced the boy to touch him.

After about 20 minutes, Jacob told Heinrich he was cold, Heinrich recalled. He told Jacob he could get dressed.

"Take me home," the boy asked, but Heinrich said he couldn't take him all the way home, and Jacob started to cry.

When Heinrich saw a police car go by, he got scared.

"I panicked and pulled the revolver out of my pocket," Heinrich said. "It was never loaded until that point. I loaded it with two rounds and told the victim to turn around, I had to go to the bathroom. He didn't know what I was doing."

Then, Heinrich said, with Jacob turned away, he raised the revolver to the boy's head, turned his own head away, and pulled the trigger.

The gun clicked once, but didn't go off. He pulled the trigger again, and it fired. When he looked back, the boy was still standing, so he shot once more. Jacob fell to the ground.

The execution over, Heinrich drove back to his apartment in downtown Paynesville and waited a couple of hours before returning to the scene after midnight to hide Jacob's body. He dragged it about 100 yards, then decided the shovel he brought wasn't big enough to do the job quickly. He walked to a nearby construction company and found a Bobcat.

"I placed Jacob in the grave and I covered him back up," Heinrich said. He returned the equipment, covered the grave with grass and brush, then threw Wetterling's tennis shoes into a ravine as he walked back home.

Heinrich returned a year later under the cover of darkness to find Jacob's red jacket sticking out of the shallow grave.

He gathered as much as he could into a bag — the boy's jacket, bones and skull — and carried it all across the highway. He dug another grave about 2 feet deep, this time with an Army entrenching tool.

He put Jacob's bones in the grave, placed the jacket on top and covered him a final time.

For almost 27 years, Heinrich guarded his secret from authorities.

'Stole our innocence'

"Finally, we know," Luger said Tuesday. "We know the truth. Danny Heinrich … is the confessed killer of Jacob Wetterling."

The day Jacob was abducted "stole our innocence," Luger said.

Authorities had interviewed Heinrich about Jacob shortly after he disappeared. They reinterviewed him at least twice in 1990, also searching his father's house, where he then lived.

They found six photos of children, including one showing a boy wrapped in a towel exiting a shower, and another of a boy in his underwear. No charges resulted.

In February 1990, Heinrich was arrested on probable cause in the kidnapping and sexual assault of a Cold Spring boy, Jared Scheierl. Heinrich said he was innocent and was released without being charged.

Authorities had long believed Wetterling's and Scheierl's cases were connected.

In 2015, using new technology, authorities tested DNA from Scheierl's sweatshirt and found that it matched Heinrich. That led them to search Heinrich's house, where they discovered more than 150 graphic images. They arrested him a final time, charging him with 25 counts of child pornography.

Ten days ago, Luger said, Heinrich's defense team reached out with an offer — a full confession, detailed directions to Jacob's grave — but only if he wouldn't be prosecuted for Jacob's killing, or an earlier assault on Scheierl.

"This was not an opportunity we could pass up," said Luger, who described a "volatile and unpredictable" Heinrich as someone who might change his mind at any time. "We have to grab the moment."

What followed were several tense days as investigators worried that Heinrich might back out of the deal. None of them, Luger said, will forget the moment when searchers discovered the first fragments of Jacob's red St. Cloud hockey jacket. They later found the bones and teeth of a child, then a T-shirt printed with the name: Wetterling.

Heinrich faces the maximum 20-year sentence on the single federal child pornography charge. All other child pornography charges were dropped. At the end of his prison sentence, Stearns County Attorney Janelle Kendall said, Heinrich could be committed to the state's sex offender program and "may never be released again."

Door finally opens

Friends and supporters began arriving at the courthouse Tuesday wearing buttons printed with Jacob's photo.

"We have been banging on this door forever and now it is opening," said Alison Feigh, program manager for the Jacob Wetterling Resource Center and one of Jacob's middle school classmates.

When first announcing the federal child porn charges against Heinrich last year, federal authorities named him a "person of interest" in Wetterling's abduction.

Court documents also raised questions about whether Heinrich was responsible for a series of disturbing attacks on young boys in Paynesville months before Jacob was taken. All of the attacks took place within blocks of Heinrich's apartment.

Nine months before Jacob hopped on his bike for a quick trip to the video store, Heinrich abducted Scheierl as he walked home from a cafe in Cold Spring on a January night. He confessed in court Tuesday to forcing Scheierl into the back seat of his car and sexually assaulting him.

After he was molested, Scheierl told police his attacker wore camouflage and Army boots and had a "walkie-talkie" type of device in the car. Three days later, a Stearns County deputy identified Heinrich, who was in the National Guard at the time, as a possible suspect, according to court records.

A year of change

Documents depict 1989 as a year of change for Heinrich. His car was repossessed in March. His mother remarried in May. His last day of work at Fingerhut Corp. was Oct. 8, leaving him unemployed.

Two weeks later, he abducted Wetterling.

It was a case with frustratingly little physical evidence and a frustratingly large pool of suspects, one of whom was Heinrich, who was in his late 20s at the time. Acquaintances would later describe the quiet, awkward man with thick glasses and a pudgy build as "kind of an oddball."

Nearly 30 years later, Heinrich still wore thick glasses as he stood in court, throngs of reporters watching, as he finally told the world what he had done.

Afterward, Patty Wetterling thanked everyone involved in the effort to bring her son home, but added that her family wasn't ready to talk much yet.

"We need to heal," she said. "There's a lot of lessons learned and there's a lot of work to do to protect all our world's children."

She spoke not about how Jacob died, but how he lived.

"He's taught us all how to live, how to love, how to be fair, how to be kind," she said. "He speaks to the world that he knew, that we all believe in. It is a world worth fighting for. His legacy will go on."

Staff writers Stephen Montemayor, Jenna Ross and Paul Walsh contributed to this report. 612-673-7102 612-673-4008