A former state GOP treasurer who was accused of bathing with a 5-year-old boy will avoid jail time after pleading guilty to a child endangerment charge.

Gary Schaffrick, 53, the former state Republican party treasurer, sparked controversy inside the party in 2016 when he continued to perform duties while fending off police claims that he bathed naked with the boy and gave the boy candy to sleep in his bed.

Schaffrick, of Bristol, was sentenced Wednesday to a 10-year suspended jail sentence and five years of probation after pleading guilty to one count of risk of injury to a minor, according to his lawyer.

His charges stemmed from a stint of babysitting the boy, who was the child of a relative, in 2015.

His guilty plea does not include admission to those specific acts or an apology to the family, Schaffrick’s Bristol-based lawyer, Jodi Zils Gagne, said.

Essentially, he “disagreed with the prosecutor ... but recognized the risks of going to trial,” Gagne said.

He was charged on March 8, 2016 and announced his resignation on March 28. But the charges didn’t mark the end of Schaffrick’s political career.

In April of 2016, he was chosen as one of two Connecticut Republicans to help organize the party’s national convention.

That choice received criticism from state party insiders who noted that the same week Schaffrick was serving the national committee, former GOP House Speaker Dennis Hastert had been sentenced for paying hush money to a child rape victim.

Schaffrick earned around $4,000 for logistics and record keeping work after his arrest, according to Federal Election Commission records.

Despite the payments, state party leaders said at the time that they had severed ties with Shaffrick.

“He’s not an employee,” CT GOP chief J.R. Romano told the Post in August 2016, after the GOP convention. “He’s no longer at the party.”

According to Romano, Schaffrick had also served as a member of the 72-member Republican State Central Committee. Romano did not respond to a request for comment.