NEW YORK — A federal judge has overturned the conviction of a former New York City police officer accused of plotting to kidnap, kill and eat young women, due to insufficient evidence.

A jury had concluded that Gilberto Valle 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.

See also: 7 Times Facebook Activity Got People Into Legal Trouble

However, Judge Paul Gardephe disagreed, and ruled late Monday that there was insufficient evidence to support the Valle's conviction, defense attorney Julia Gatto said Tuesday.

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

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."

Valle, who could have faced life in prison, was acquitted of kidnapping conspiracy charges, the most serious count he faced.

This photo shows a passage of a Federal complaint filed in New York, Thursday, Oct. 25, 2012, against New York City Police Department officer Gilberto Valle. Image: Richard Drew/Associated Press

He was convicted in March 2013 and had not yet been sentenced.

The judge planned a hearing Tuesday morning on the status of the case; Valle has been jailed since his arrest in 2012.

"Gil Valle has been in jail for 18 long months, 7 months in solitary confinement, for a crime he absolutely didn't commit," said Gatto. "We're relieved he will be free and incredibly grateful to Judge Gardephe for upholding the awesome and fundamental legal principles at stake here, including our core freedom to be able to think what we want free of government intrusion."

A call to a spokesman for Manhattan federal prosecutors was not immediately returned.

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.

This photo shows a passage of a Federal complaint filed in New York, Thursday, Oct. 25, 2012, against New York City Police Department officer Gilberto Valle. Image: Richard Drew/Associated Press

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.

In one of the numerous online conversations shown to the jury during the trial, Valle told a man he met in a fetish chat room, "I want her to experience being cooked alive. She'll be trussed up like a turkey. ... She'll be terrified, screaming and crying."

In this Oct. 25, 2012, file courtroom drawing, Federal Defender Julie Gatto requests bail for her client, New York City Police Officer Gilberto Valle, right, at Manhattan Federal Court in New York.

In another exchange, Valle suggested a woman he knew would be easy prey because she lived alone. The men discussed cooking her, basted in olive oil, over an open fire and using her severed head as a centerpiece for a sit-down meal.