As friend Emily Loechen comforts him, James van Kuilenburg talks about some of his experiences as a transgender student in Frederick County, Md. (Essdras M Suarez/For the Washington Post)

When James van Kuilenburg used the bathroom at his Maryland high school, he always worried. Would he be taunted by his classmates? Would he be shamed or beaten? Most of the time, he avoided the risk altogether.

“You don’t feel safe,” the teenager said, five years after coming out as transgender.

But van Kuilenburg and others in Frederick County hope this year marks a turning point across the Maryland system’s 67 schools as a new policy takes hold that is regarded as one of the most progressive in the state.

The policy spells out that bathrooms and locker rooms should be used according to gender identity and provides alternatives for students uncomfortable for any reason. It also covers privacy, preferred names, dress codes for major events and participation in sports teams.

“I see it as one of the most comprehensive transgender student policies in the country,” said Jabari Lyles, executive director of GLSEN Maryland, which advocates for LGBT students on issues of education.

Members of the Frederick County Public School Trans Student Support group talk about their struggles, achievements and frustrations. From left are Maxx Frazier, 15, James Van Kuilenburg, 17, Emily Loechen, 16, and Asher Burrows. (Essdras M Suarez/For the Washington Post)

Some in Frederick see the policy’s adoption — in a growing exurb of Washington once viewed as largely rural and conservative — as a reflection of changing politics, greater diversity, dogged student activism and a school board that did not shy away from a contentious issue.

“It was sort of unstoppable,” said Alicia Barmon, a Frederick psychotherapist who joined in rallies and meetings.

But critics have spoken out, too. A suit was recently filed on behalf of a mother and her 15-year-old daughter, asserting the girl’s rights to bodily privacy and saying the teen fears for her safety and feels humiliated to undress in front of “the opposite sex.” The family’s attorney, Dan Cox, an unsuccessful Republican candidate for Congress last year, declined to comment on the suit, which at points invokes totalitarian regimes and Nazi death camps.

Frederick school officials will soon respond to the complaint in court, said attorney Donny English. “We look forward to defending our policy, which we think is inclusive and respects everyone’s rights,” he said.

The push for change started in February, when van Kuilenburg and others went to Frederick’s school board as the Trump administration revoked federal guidance that said transgender students have the right to use public school restrooms that match their gender identity. They said they felt unsafe and urged local action.

“There’s no procedure, and there’s no policy,” testified Maxx Frazier, a transgender student who is 15, “and it’s worrying because right now with the election and the results of that, a lot of people feel they have the right to hate.”

Led by van Kuilenburg, who attends Gov. Thomas Johnson High School in Frederick, students told the board about school experiences — crude comments, fear of harassment, being outed when teachers use the wrong name. They organized an email campaign, launched a Facebook page and held two rallies. They were joined by parents, classmates, educators and community members.

“We see this as being on the right side of history, and an overall sign of fairness,” said Tyler Oyler, 34, the owner of a craft brewery who heard about the effort through social media.

The Frederick deliberations came at a time of flux nationally, with both the Trump administration’s action and a U.S. Supreme Court decision to remand a key case — involving Virginia student Gavin Grimm — to a lower court, leaving many without the legal clarity they sought.

Some school districts have responded with local policies, as Frederick did, but a large majority are accommodating students on a case-by-case basis, out of the spotlight, said Francisco M. Negron Jr., chief legal officer for the National School Boards Association.

Dozens of legal complaints have been filed in recent years on both sides of the debate, he said.

“The priority for schools is keeping students safe, and they are squarely in the middle of this,” he said.

The policy that emerged in Frederick largely reflected what the district was already doing on key issues such as bathrooms but it is more clear and concrete, with the idea of increasing consistency and compliance, supporters say.

Teachers backed the change, said Melissa Dirks, president of the Frederick County Teachers Association. “It’s brought a peace of mind to our students that they will be treated more fairly and equitably, and has also brought about more training for staff,” she said.

But as the board voted in June, opponents spoke out.

“One of our problems with this policy is it appears to be concerned only with the rights and affirmations of transgender students,” said Cindy Rose, speaking for the Republican Women of Frederick County. “Will there be a policy protecting the band geek, the math nerd and the other children who have felt unwelcome and bullied for decades? Will they get a similar carve-out?”

Rose described the issue as a question of privacy rights and “whether boys should be able to watch girls undress and vice versa.”

Other critics cited a greater risk of emotional distress or sexual assault, and a string of speakers took issue with a privacy provision that allows students to express a gender identity at school that parents potentially may not know about.

As board members voted, several recounted months of getting to know an unfamiliar subject and thinking it through.

“My opinions have changed, and a lot of the concerns I had I find no longer to be valid,” board member Ken Kerr said.

Board member Michael Bunitsky compared the issue with other historical flash points: integrated schools, voting rights, women’s rights.

“What was once controversial we now consider to be as American as apple pie,” he said.

Van Kuilenburg held up his transgender flag after the policy passed, 5 to 1, with the student member also in favor. He hugged friends and supporters. That night, he cried. The 17-year-old describes the policy as “perfect,” a change he never imagined.

“We created history in Frederick County,” he said.

He recalled that when he came out as transgender at age 12, the principal at his West Virginia middle school had no idea what to do. The principal told the then-seventh-grader to use the bathroom in the nurse’s office and removed him from his P.E. class, he said.

“The years I felt completely hopeless,” he said, “and I felt that nothing would get better — it was all worth it.”

Students say they recognize that the policy won’t change everything immediately, but it has begun to make a difference.

Asher Burrows, 15, who identifies as neither male nor female, recalls being singled out last year for dress code violations that seemed vague and related to clothing that teachers appeared to consider too feminine.

“It’s very embarrassing,” the teenager said. “It makes me feel that I am not allowed to wear the clothes that make me feel comfortable in my own skin.”

This year, there have been fewer such moments, the teenager said.

Van Kuilenburg said he thinks school is more welcoming — and so is the county he lives in.

With the lawsuit challenging the policy underway, students and their allies launched another social media campaign to show the breadth of their support. They asked people to contribute photos of themselves with a sign that says “#IAmFrederick and I support trans youth because . . . ”

“No child should be afraid to be themselves!” one person wrote.

Said another: “School should be about learning, not survival.”