A former NYPD police officer has been ordered to home detention pending an appeal by the government after a judge overturned his conviction of plotting to kidnap, kill and eat young women.

Judge Paul Gardephe ruled late Monday there was insufficient evidence to support the conviction of Gilberto Valle. He acquitted him of kidnapping conspiracy charges.

"The judge's well-reasoned decision validates what we have said since the beginning: There was no crime," said Valle's defense attorney Julia Gatto. "Gil Valle is innocent of any conspiracy. Gil is guilty of nothing more than having unconventional thoughts." 

The judge set Valle's bail at $100,000; he's expected to be released later Tuesday.A smiling Valle hugged his lawyers. Valle could have faced life in prison.

He was convicted in March 2013. A jury concluded he wasn't just fantasizing when he conversed online with others he had never met about killing and cooking his wife and others in a cannibalism plot.

In his 118-page opinion, first reported by The New York Times, Gardephe said: "The evidentiary record is such that it is more likely than not the case that all of Valle's Internet communications about kidnapping are fantasy role-play." 

 Prosecutors had argued that Valle took steps to carry out his plot, including looking up potential targets on a restricted law enforcement database; searching the Internet for how to knock someone out with chloroform and where to get torture devices and other tools.

Gardephe upheld Valle's conviction on a charge of illegally gaining access to the law enforcement database, which carried a maximum sentence of one year. Valle was fired after his conviction.