Updated

An Alabama high school teacher accused of having sex with two male students has had her criminal case tossed by a judge who ruled the state's teacher-student sex law unconstitutional.

Decatur High School history teacher Carrie Witt, 44, was charged with having sex with a male student who was 17 when the relationship started, and another male student who was 18.

She convinced Circuit Court Judge Glen Thompson that in Alabama the age of consent is 16 and that police never had accused her of having used her position to coerce the students into having a sexual relationship.

75bbcdba-Witt720

Witt had been placed on administrative leave after her arrest last year. (LinkedIn)

“Had it have been some sort of coercion it would be a different story,” her attorney Robert Tuten told Fox News Friday. “The state has never said it was other than consensual. If that is the case they cannot charge (her) with a crime.”

He added: “It doesn’t mean we think teachers should be having sex with students, but this is not the way to handle that.”

Tuten said Witt was “glad” the judge had ruled in her favor.

Alabama lawmakers made teacher-student sex under the age of 19 a crime in 2010.

fae6847f-Witt558

Witt had taught history at Decatur High School (Facebook)

Decatur police arrested Witt in 2016 after investigating a complaint that she had been involved in a sexual relationship with a student younger than 19. She was placed on administrative leave after her arrest and has been free on $10,000 bail.

Thompson found that while there may be a gap in power between teacher and student, it "clearly does not exist between every school employee and every student regardless of where that student is enrolled," WHNT-TV reported.

He held that prosecutors must prove a school employee “was actually in a position of authority over the victim/student and that the position of authority was abused to obtain consent,” according to the station.

“The statute at hand embeds an irrebuttable presumption that any sexual encounter between an employee of any school and any student (without qualification as to class, school, or school system) is conclusively the result of misuse of authority," wrote the judge, the station reported.

“The law takes away the right of the employee to assert a defense that legal consent that was freely and legitimately given — abrogating the student’s capacity to consent.”

Thompson’s ruling also dismissed a case against David Solomon, a Falkville High School teacher’s aide charged last year with having sex with a 17-year-old female student.