The former bodega clerk convicted in the infamous 1979 disappearance and murder of little Etan Patz should be given a new trial — or set free, a federal appeals court ordered Monday in a shocking ruling.

Pedro Hernandez, who was found guilty in 2017 of the 6-year-old boy’s slaying, had argued that jury instructions during his high-profile Manhattan trial were improper and prejudiced the outcome.

“We conclude that the state trial court contradicted clearly established federal law and that this error was not harmless,” the appeals panel wrote in its ruling, first reported by the New York Times.

Ethan Patz went missing in 1979. Stanley Patz

In this Nov. 15, 2012, file photo, Pedro Hernandez appears in Manhattan criminal court in New York. AP

Etan’s disappearance had baffled authorities for years after he vanished from a SoHo street the very first time his parents allowed him to walk alone to this school bus stop back on May 25, 1979.

Hernandez didn’t become a suspect until 2012 when cops received a tip that he’d apparently confessed during a prayer group to killing a child in New York.

During a videotaped interrogation, Hernandez later confessed to luring the boy into the basement of the bodega near his bus stop with the promise of a soda.

He admitted to strangling Etan until he went limp.

“Something just took over me,” Hernandez said in one of the recorded confessions, adding that he’d wanted to tell someone, “but I didn’t know how to do it. I felt so sorry.”

Hernandez’s first trial ended in 2015 with a hung jury.

In 2017, he was ultimately found guilty of kidnapping and murder and sentenced to the maximum of 25 years to life in prison.

A New York Police Crime Scene Unit arrives as officials search for evidence Thursday, April 19, 2012 at the intersection of Prince and Wooster Streets in New York. Chad Rachman/New York Post

The little boy became one of the first missing kids ever pictured on milk cartons and the anniversary of his disappearance was designated National Missing Children’s Day.

The child’s body was never recovered.