A high school teacher in Utah arrested earlier this year for a tryst with a 17-year-old male student is out of jail due to a legal technicality.

Sarah Lewis, a former teacher at Landmark High School in Spanish Fork, admitted to having sexual intercourse with the male student in her Payson home, according to a probable cause statement obtained by KUTV.

The 27-year-old admitted in court to giving the student vodka prior to having sex, and then told the teen to deny their relationship if anyone ever asked.

She was originally arrested in January and charged with rape, which was later reduced to one count of forcible sexual abuse. The ex-teacher's public defender, Tom Means, advised her to enter a plea of guilty, meaning she would face between 1 and 15 years in state prison.

MIDDLE SCHOOL TEACHER, 50, ARRESTED FOR SEX TRYST WITH TEEN BOY STUDENT

But Means then found an amended statute in Utah Code that states, "if a minor is 16 or 17 years old, the rape charge can be reduced to Unlawful Sexual Conduct, when applied to a person who holds a relationship of special trust: such as an adult teacher, employee, or volunteer," according to court documents obtained by KUTV.

Utah law applies stricter punishments if there is more than a seven year age gap between the minor and the offender.

The ex-teacher was then charged with a third degree felony instead of the first degree rape felony, and released with no further jail time.

A local defense attorney told KUTV the change in the law creates balance, and isn't a loophole.

"Legislators have taken the teacher portion out of the equation," Stephen R. Allred, a defense attorney with Zabriskie Law Firm, told KUTV. "I don't consider this a loophole. These 16 and 17 year olds do have a choice, and they have chosen to engage in this."

ONE-TIME 'TEACHER OF THE YEAR' GETS 10 YEARS IN JAIL OVER TEEN BOY SEX PARTIES

County prosecutors however believe anyone under the age of 18 can't legally consent to sexual activity.

"Lewis occupied a position of special trust as a teacher," Deputy Utah County Attorney Ryan Peters told the television station.

Lewis taught at Landmark High School, an alternative school with about 340 students in grades 10-12, and the school’s website listed her as a social studies teacher and dance instructor, according to FOX13 Salt Lake City.

Lana Hiskey of the Nebo School District told FOX13 that Lewis was hired in 2014 and taught girls and boys dance classes in a program Lewis created.