A Brooklyn judge handed the founder and CEO of Rentboy a six​-​month sentence Wednesday — saying she was convinced he built what was once the largest gay escort site ever “for a good purpose.”

“I struggled with sentencing of this case,” Brooklyn Federal Court Justice Margo Brodie told Jeffrey Hurant. “It kept me up at night.”

“I am convinced you started this site for a good purpose,” said Brodie.

The jurist added she relied on the deluge of letters submitted on the 52-year-old’s behalf.

“There is no doubt in my mind based on everything that has been said that you will continue to be a productive member of society,” she told him.

“I never intended to hurt anyone,” Jeffrey Hurant told the packed courtroom before he was sentenced. “I’m very sorry if I ever put anyone in harms way. I want to apologize to everyone I hurt.”

The Rentboy founder had initially faced up to 20 years behind bars on charges of promoting prostitution and conspiracy to commit money laundering.

He pleaded guilty last October, admitting to operating an online brothel that knowingly allowed escorts to pay for ads that touted sexual services.

“Money can’t buy you love … but the rest is negotiable,” the site once crowed.

As part of the deal, he has agreed not appeal the sentence.

Brodie also ordered Hurant to shell out $7,500 in fines.

“We must fearlessly fight for the rights for consensual adults to choose what they do with their bodies,” Hurant said as he left court, hugging some 30 friends and family members who had come to show their support.

“Although we are very disappointed that he has been sentenced to a term of incarceration, we are also very grateful to the court for acknowledging Rentboy.com was conceived for great intentions and for acknowledging all the good it has done for the [LGBTQ} community,” defense attorney Michael Tremonte said.

Hurant will surrender to begin serving his sentence at an undetermined date.