An Orthodox Jewish man pleaded guilty to sex abuse charges Friday in a deal that lets him serve as little as three months behind bars — ending a case that the Brooklyn district attorney had made a priority.

Baruch Lebovits, 62, answered “Yes” eight times as Brooklyn Supreme Court Judge Mark Dwyer asked him whether he had engaged in oral sex with a teenage boy on eight different occasions in 2004 and 2005.

The case against Lebovits became a political hot potato in the 2013 race for Brooklyn district attorney when then-DA candidate Ken Thompson sent then-DA Charles Hynes a letter in November asking that no plea deal be given to Lebovits before Thompson took office.

After Thompson was elected, he assigned top homicide prosecutor Anna-Sigga Nicolazzi to the case.

Lebovits was convicted in 2010 of the same charges he pleaded guilty to Friday and sentenced to 32 years behind bars before that conviction was overturned in 2012.

Prosecutors offered Lebovits a sentence of two to six years in court Friday, but in a sidebar, Dwyer told the attorneys that he would give a sentence of two years if Lebovits pleaded guilty, said a source close to the case.

After accepting Lebovits’ guilty plea, Dwyer said he arrived at the sentence of two years by checking state records and finding that was the average sentence for defendants with similar charges.

The deal gives Lebovits two years in a city jail, but because defendants typically serve just eight months on a one-year jail sentence — and because Lebovits already served 13 months behind bars — he’s expected to do only about three months in a city jail.

“The DA has been ready and willing to proceed to trial, but he understands he has to balance the needs of justice with what would be best for the complainant,” Nicolazzi said in court Friday.

“The fact that this case is finally concluded is a tremendous relief to the Lebovits family and to the victim and his family. Everybody is looking forward to moving on,” said defense attorney Arthur Aidala.

Lebovits declined to comment as he walked out of court.