A married substitute teacher in Michigan convicted of sexually assaulting a 15-year-old boy was scolded by a judge and a prosecutor during her sentencing Wednesday after admitting that she “tried to find comfort wherever” she could with the illicit affair.

Allyson Brittany Moran, 27, was sentenced to 25 months to 15 years in prison for third-degree criminal sexual conduct, but not before a prosecutor and judge blasted her for blaming the victim by claiming he initiated the sexual assaults, the Lansing State Journal reports.

“She used her position to gain his trust … and she took that and manipulated it into something for personal gratification,” Assistant Prosecuting Attorney Steve Kwasnik said. “She lured him into an adulterous affair.”

Moran, a long-term substitute chemistry teacher and a girls’ soccer coach at Stockbridge High School, was arrested in September 2017, months after the 15-year-old boy told his girlfriend about the sexual assaults. A relative of his later called police, he testified.

But Moran’s attorney, Sean Carroll, insisted the incidents were the culmination of a “perfect storm” of events for his client, including a miscarriage, a new job within the school district and ongoing acrimony with her husband. Moran has since been punished enough by losing her career and having to register as a sex offender, according to Carroll, who asked the judge to sentence her to probation.

“She’s faced alienation, stigma and shame,” Carroll said. “She’s grown from the situation.”

Moran, for her part, apologized to the teen’s parents and cited her miscarriage as part of the reason why she “slipped away,” according to the newspaper.

“I tried to find comfort wherever I could,” Moran said. “At 27, I will have a lifetime of consequences that will surpass any prison time.”

That apparently struck a chord with Ingham County Circuit Court Judge Joyce Draganchuk, who admonished Moran for preying on a “vulnerable” victim.

“I wish so much that you had talked more about the lifetime of consequences [he] has,” Draganchuk said. “He’s criticized and judged and he didn’t do anything wrong.”

The assaults have left the teen — once an outgoing, popular and jovial kid — unrecognizable compared to his former self, his mother told the judge.

“She took things from him he’ll never get back,” she said. “Tell me how it’s a child’s fault that his teacher preyed upon him.”

The boy’s mother testified that her son also still carries the guilt of Moran’s attempted suicide following her arrest. He’s also teased at school, which he now dreads, and he hopes to graduate early to avoid the comments, she said.

Court documents indicate that Moran invited the teen to her home in Dansville in April 2017 after telling him her husband was out of town. She opened the door while wearing only a bra, underwear and an open robe.

She then took the teen into a spare bedroom, where she sexually assaulted him. She invited the boy back to her house days later and sexually assaulted him a second time, according to court documents.

In March 2017, Moran and the teen then started communicating on Snapchat, where the teen said she sent him nude photos of herself. Moran also chatted with other male students on the app, court records show.

“He’s missing out on his teenage years because of what she did,” the boy’s mother told Draganchuk.