A New Jersey appeals court has tossed the 2012 conviction of a former Rutgers University freshman who trained a webcam on the bed of gay dorm-mate Tyler Clementi, an aspiring violinist who then committed suicide.

In presenting a case against accused cyber-bully Dharun Ravi, Middlesex County prosecutors focused too intently on the state of mind of the tragic victim, who was humiliated to learn that his gay tryst had been simulcast for a roomful of Ravi’s taunting pals.

Clementi, 18, killed himself days later, in September, 2010, by leaping from the George Washington Bridge. The last thing Clementi viewed online before the suicide were tweets by Ravi mocking the encounter and urging pals to tune in again for more.

Tyler ClementiAP

Ravi has argued through his lawyers that he had nothing to do with the death and that his intent was never to cause Clementi harm.

The decision “shows us how much more work needs to be done,” Clementi’s parents, Joe and Jane, responded in a statement, promising to continue working through the Tyler Clementi Foundation “to create a kinder, more empathetic society where every person is valued and respected.”

In describing where prosecutors went wrong, the court wrote: “The State used evidence revealing the victim’s reserved demeanor and expressions of shame and humiliation as a counterweight to defendant’s cavalier indifference and unabashed insensitivity to his roommate’s right to privacy and dignity.”

The ruling continued, “The prosecutor aggressively pressed this point to the jury in her eloquent closing argument. It is unreasonable to expect a rational juror to remain unaffected by this evidence.”

Ravi’s family praised the ruling, which tosses completely the four most serious felonies, all for bias intimidation.

Prosecutors can retry Ravi on the remaining 11 counts, which include invasion of privacy, tampering with evidence and hindering apprehension.

But Ravi, who has already served 20 days of 30-day sentence, would not face any further jail time.

Prosecutors also have 20 days to decide whether to appeal to New Jersey’s highest court.

“It’s far from over,” Ravi’s attorney Steven Altman told nj.com. “I’m extraordinarily pleased with the decision. I haven’t spoken with the Ravi family yet, but I can only imagine they’re pleased as well.”