By Amanda Sakuma and The Associated Press

The Minnesota man who confessed to abducting and killing 11-year-old Jacob Wetterling more than 27 years ago was sentenced Monday to two decades behind bars, drawing to a close a case that drew nationwide attention and vexed the public.

Jacob Wetterling Courtesy of National Center for Missing and Exploited Children

Danny Heinrich, 53, was sentenced to 20 years in federal prison on child pornography charges — part of a plea deal made in exchange for admitting that he took Jacob’s life.

In October, Heinrich confessed to the U.S. District Court in Minneapolis that he abducted Jacob and sexually molested him on Oct. 22, 1989. He admitted that he then shot the 11-year-old and buried his body in a gravel pit.

Speaking at his sentencing hearing on Monday, Heinrich apologized to his victims and their loved ones, saying he kept silent for all these years to avoid bringing shame on himself and his family.

Danny Heinrich: I am truly sorry for the pain I caused the victims and their families. — Susan-Elizabeth (@susanelizabethL) November 21, 2016

A grisly crime

A masked gunman had abducted Jacob while he was riding bikes with his brother and a friend near his home in central Minnesota.

Police repeatedly questioned Heinrich as a potential suspect in early in their investigation. But Heinrich maintained over the years he had no connection to Jacob's disappearance.

Daniel Heinrich Sherburne County Sheriff's Office

The case took a turn last year, when U.S. Attorney Andrew Luger unveiled new technology that matched Heinrich’s DNA to the kidnapping and sexual assault of yet another Minnesota boy back in January 1989.

Police searched his home and found 19 three-ring binders full of child pornography, along with VHS tapes recorded by Heinrich himself.

Heinrich pleaded guilty to one count of possessing child pornography. And while the statute of limitations on Jacob’s kidnapping and assault had long expired, prosecutors agreed to not charge him with murder as part of a plea deal requiring him to confess to killing Jacob and to take authorities to where he buried the boy's remains.

After Jacob's disappearance, his family rose to prominence as national advocates for missing children. In 1994, Congress passed a law in Jacob’s name requiring states to build sex-offender registries.

Wetterling's family appeared before the court on Monday to express their anguish and pain to the 11-year-old boy's confessed killer.

"He broke my heart, my soul and every fiber of my being when he murdered our Jacob," Jacob's mother, Patty Wetterling, said during the hearing, according to NBC station KARE in Minneapolis. "My heart hurts for my children... for Aaron... who kept waking up and realizing it wasn't a nightmare."