The New Jersey judge who refused to try a 16-year-old boy who was accused of rape as an adult — because he comes from a “good family” — has decided to step down, according to officials.

The state Supreme Court granted Judge James Troiano’s request to resign on Wednesday and terminated his services effective immediately.

The longtime family court judge reportedly retired in 2012, but was still hearing cases on a part-time basis in Monmouth County Superior Court.

He had been assigned to a case last year involving a 16-year-old boy who allegedly raped a 16-year-old girl while she was intoxicated — and sent a video of the assault to his friends — when Troiano made his controversial comments.

“This young man comes from a good family who put him into an excellent school where he was doing extremely well,” the judge said at the time. “He is clearly a candidate for not just college but probably for a good college.”

Troiano got bombarded with death threats after word got out about the proceeding, with some reportedly calling him “a bigot” and “detriment to this country.” He is one of two judges to be removed from the bench this week.

Superior Court Judge John Russo got the ax Wednesday after asking a rape victim in 2016 whether she attempted to keep her legs closed during her alleged assault. The state Supreme Court recommended his removal and he will now have until Aug. 19 to offer evidence proving why he should keep his position.

“Sexual assault is an act of violence. It terrorizes, degrades, and induces fear in victims,” said Chief Justice Stuart Rabner in a statement. “Without question, it is a most serious matter in which fault lies solely with the perpetrator, not the victim. And our State has a strong interest in protecting victims of sexual assault and domestic violence.”

Russo — who is also reportedly facing a sexual harassment suit from his former law clerk — has been suspended without pay, pending the conclusion of his removal proceedings.

The state’s court system on Wednesday announced the launch of a sex crime training program for all judges.

“The program will focus on an enhancement of existing training for judges in the areas of sexual assault, domestic violence, implicit bias, and diversity,” said Judge Glenn A. Grant, acting administrative director of the New Jersey Courts, in a press release. “Superior Court judges (including all recall judges), Tax Court judges, Appellate Division judges, and Supreme Court justices will participate in this training session. A similar mandatory training will be scheduled for all Municipal Court judges.”

State officials hope the education conferences “will serve to enhance understanding of the complexities and nuances associated with sexual assault, sex offenses, and domestic violence matters and to raise awareness of the impact of implicit bias on decision-making, while providing skills for judges to recognize and respond to their preconceptions.”

“The programs also will train judges in effective communication skills that will aid them in delivering clear decisions that are rooted in the law, respectful of victims, and understandable to the public while protecting the rights of the accused,” Grant said. In addition to the statewide education conferences, within six months, and annually thereafter, each vicinage will hold local training sessions for judges to ensure that local court environments reflect and support our Judiciary-wide values. This annual training, developed in partnership with local subject matter experts, also will be mandatory for all judges. Judiciary staff will receive similar mandatory training.”

With Post wires