SALEM, Ore. (AP) — A school district near the Oregon state capital can allow transgender students to use locker rooms and bathrooms of the gender they identify with instead of their birth gender, a federal appeals court ruled Wednesdays.

Some parents and students at a high school in Dallas, Oregon, had filed the lawsuit in 2017, saying the policy caused embarrassment and stress. A lower court had previously ruled the school policy was permissible, a decision affirmed by the the Ninth Circuit Court of Appeals.

“We hold that Dallas School District No. 2’s carefully-crafted Student Safety Plan seeks to avoid discrimination and ensure the safety and well-being of transgender students,” the appeals court said.

It said the district’s policy does not violate students’ constitutional rights or a law that protects people from discrimination based on sex in education programs.

Similar lawsuits have been dismissed by courts in other parts of the country.

The ACLU, ACLU of Oregon, and Lane Powell represented Basic Rights Oregon in the case to defend the Dallas School District.

The district “has done the right thing all along, following the law that allows transgender students the right to use the bathroom or locker room that most closely aligns with their gender identity,” said Nancy Haque, executive director of Basic Rights Oregon. “This simple act provides a more supportive and affirming learning environment.”

About 15,000 people live in Dallas, a town in an agricultural area 15 miles (24 kilometers) west of Salem, the state capital.

___

Follow Andrew Selsky on Twitter at https://twitter.com/andrewselsky