By Timothy Mclaughlin

(Reuters) - A Minnesota man was sentenced on Monday to 20 years in prison on a federal child pornography charge as part of a plea agreement earlier this year in which he confessed to assaulting and killing a boy in 1989, the U.S. Department of Justice said.

Danny Heinrich, 53, was handed the sentence in the U.S. District Court in Minneapolis. Heinrich confessed in September to kidnapping, sexually assaulting and fatally shooting 11-year-old Jacob Wetterling in October 1989, in a case that stumped investigators for decades.

Heinrich's confession, in addition to helping lead police to the spot where he buried Wetterling's body, was part of a deal in which he pleaded guilty to a federal child pornography charge, but did not face charges in the killing.

Wetterling's parents, Patty and Jerry Wetterling, became advocates for missing children after his disappearance.

In court on Monday, Heinrich apologized to the Wetterlings, the Minneapolis Star Tribune reported.

"The heinous acts of selfishness are unforgivable ... I'm so sorry," Heinrich said, according the Star Tribune.

“Today’s sentencing marks the close of a sad chapter in Minnesota history. Danny Heinrich hurt countless lives, none more tragic than Jacob Wetterling," U.S. Attorney Andrew Luger said in a statement following the sentencing.

Heinrich was named a person of interest in the abduction of Wetterling in October 2015 and was charged with possession and receipt of child pornography.

Authorities searched Heinrich's home in July 2015, finding child pornography in three-ring binders and on a computer hard drive. They also found dozens of videotapes Heinrich appeared to have filmed of young boys delivering newspapers, playing or riding bicycles, officials said, but Wetterling's picture was not among them.

In his confession in September, Heinrich recounted shooting Wetterling twice and also admitted to sexually assaulting another 12-year-old boy.

Patty Wetterling said after the confession her son's legacy would live on and that her family needed time to heal.

"We pause to reflect on the joy and kindness Jacob brought to his family and many others," the Jacob Wetterling Resource Center, a child safety advocacy organization founded by the Wetterlings after Jacob's disappearance, said in a statement on Monday.

"Today’s sentencing changes nothing for the Jacob Wetterling Resource Center’s mission. There is much more work to do to address and prevent the abuse and exploitation of children," the statement added.

(Reporting by Timothy Mclaughlin in Chicago; Editing by Bernadette Baum and Matthew Lewis)