A former conservative rabbi in Sharon pleaded guilty to stealing nearly half a million dollars from his temple’s charity fund in order to pay an online blackmailer, but could see his charges dismissed if he is not charged with any crimes in the next 12 months.

Barry Starr, who served as the rabbi of Temple Israel for 28 years, pleaded guilty to using the temple’s charitable fund to pay a blackmailer $458,300, the Boston Globe reported.

Prosecutors said the blackmailer, Nicholas Zemeitus, met Starr while looking for older women to meet for sex online, WCVB reported.

Zemeitus, of Quincy, reportedly told police that he when he arrived for a tryst at the rabbi’s home, he was surprised and upset to instead be met by the rabbi wearing women’s clothing. Starr reportedly offered to pay Zemeitus $100 to “remain quiet about the whole thing,” according to WCVB.

Later, Zemeitus told Starr he had evidence that the married rabbi had been intimate with his 16-year-old brother, and threatened to expose the allegations if Starr didn’t pay.

Starr denied those allegations, and police have previously said that their investigation revealed no evidence Barr was having sex with a minor. He was later sentenced to 4 to 5 years in state prison on  extortion and grand larceny charges, WCVB reported.

Starr has repaid all but $67,000 to the fund, the Globe reported. He and his wife have since divorced.

“He did a lot of good for a long period of time. It’s a real tragedy,’’ the temple’s president, Edward Hershfield, told the Globe.

“We are pleased the proceedings have come to an end. We are fully supportive of the district attorney’s office and the decision the judge reached... We really have moved on from this.’’