An Oregon principal has resigned after a months-long investigation into how the high school under his leadership discriminated against LGBTQ students, including forcing them to read the Bible as punishment.

When Liv Funk and Hailey Smith, two female students at North Bend High School in Coos County, began dating, they started to face discrimination — and even threats to their safety — from students and staff alike. For example, one teacher equated homosexuality with bestiality, and the school’s police officer told the young couple they were going to hell.

“One of the first major incidents happened just a couple months after the start of my sophomore year,” Funk wrote in a public letter. “My girlfriend and I were walking to her car. The principal’s son was in his car and accelerated very close to us, yelling ‘faggot’ out the window as he drove away.”

More generally, Funk and Smith said LGBT students faced harsher discipline than their straight peers, and all students had to recite Bible passages as punishment. When the two complained about the treatment, their school counselor and a professor at the Willamette University College of Law helped them take their case to the Oregon Department of Education, and eventually, the ACLU of Oregon.

After a months-long investigation, the organization found substantial evidence of discrimination and other violations of state and federal law. Public schools aren’t allowed to force any students to read the Bible, especially as punishment. And federal law protects LGBTQ students law from being punished more harshly than their straight peers.

As a result of the ACLU’s investigation, the district reached a settlement on Monday under which the principal, Bill Lucero, was forced to resign, and the school was required to ask North Bend Police Department to replace the school police officer. The district also said it’s committed to improving the climate for LGBTQ students and will remain under supervision from the state’s Department of Education for five years.

No one from the ACLU of Oregon, North Bend High School, or the district was immediately available for comment. But Mat dos Santos, legal director at the ACLU of Oregon, said in a statement that this settlement sends a clear message to everyone in the district.

“If you break the law by discriminating against LGBTQ students or engaging in religious proselytization at school, there are serious consequences,” he told the AP.