A dispute over which school bathroom should be used by a transgender child in Stafford County is sparking calls for guidance from lawmakers in Richmond and has spilled over into the Virginia House speaker’s heated primary battle.

Tempers flared last month in Stafford, a booming county north of Fredericksburg and about 50 miles south of Washington, when officials at Hartwood Elementary School told a fourth-grade class that a biological boy who identifies as a girl would be using the girls’ bathroom.

Parents, worried their children would feel unsafe or uncomfortable about the arrangement, pressured the county School Board to reverse the decision — but not before the issue garnered the attention of Susan Stimpson, the Republican challenger to William J. Howell, who represents the district where the dispute is playing out and has been speaker of the House of Delegates since 2003.

Both Howell and Stimpson have sided with the School Board and the upset parents. But in a Republican primary that is expected to attract the district’s most conservative voters to the polls on June 9, Stimpson is trying to use the episode to question Howell’s conservative credibility.

Stimpson called the district’s initial policy “a social agenda experiment” and accused Howell of being sympathetic to LGBT causes because his political action committee took $6,000 from Equality Virginia between 2006 and 2012.

“We have the speaker of the House taking donations from an organization pushing their social agenda,” she said. “Why is he silent as his friends try to push their way into the little girls’ bathroom?”

Howell, who has a 98 percent rating from the conservative Family Foundation, dismissed Stimpson’s claim as a “ridiculous and false assertion.”

“The Stafford County School Board made the right decision for our community,” he said in a statement. “This is a perfect example of why we need to emphasize local control when it comes to education. These kind of decisions should be made by our community and local leaders, not President Obama’s Department of Justice.”

The fact-checking Politifact Virginia published an item in the Richmond Times-Dispatch labeling as “false” Stimpson’s claim that Howell is allied with LGBT interests.

At a time of rapidly changing public opinion on LGBT issues, more institutions and government agencies are adopting policies intended to bar discrimination based on a person’s sexual orientation or gender identity, often igniting culture wars in the process.

In Virginia, where gay marriage became legal last year and where Gov. Terry McAuliffe (D) has embraced gay rights causes like no governor before him, a vocal community of social conservatives is pushing back.

At the meeting where the School Board overturned the school’s decision about which bathroom the child should use, Erick Kingston, a Fredericksburg parent, speculated that predators would take advantage of the situation.

“We have now opened the door for any predatory individual — student, teacher or anyone in between — within our school system to claim the gender identity to enter the restroom or locker room of the opposite sex to prey upon our children behind closed doors,” he said, according to a video of the meeting.

The family of the transgender student did not respond to interview requests. But a man who identified himself as the student’s father spoke at the meeting and said he once shared the views of parents like Kingston. His child, he said, changed his mind.

“She’s a very special person,” he said. “I only implore of all us that as we move forward we don’t trade understanding for fear and that we don’t trade misconceptions for hate.”

The School Board voted 6 to 0 to prohibit the fourth-grader from using the girls’ bathroom.

After the vote, board Chairwoman Nanette Kidby (Garrisonville) said she would like the General Assembly to address what schools should do in such situations.

“The legal landscape on these issues is unclear at this point. We await further guidance from our state delegation,” Kidby said. “We are attempting to ensure that the needs of all of our students are being addressed.”

More than a dozen states and the District have laws designed to protect students based on sexual orientation and gender identity, according to the Gay, Lesbian & Straight Education Network. Virginia does not.

LGBT rights advocates say that Title IX, the federal nondiscrimination law, is clear on the issue and supersedes any state action.

They point to a California school district where a 2013 agreement signed by the federal Education and Justice departments amended policies to clarify that “gender-based discrimination includes discrimination based on a student’s gender identity.”

And LGBT rights advocates say another landmark provision was tucked into an April 2014 document that the Education Department issued after a rash of unrelated investigations into campus sexual assaults. It says, “Title IX’s sex discrimination prohibition extends to claims of discrimination based on gender identity.”

Victoria Cobb, president of Family Foundation of Virginia, said federal court rulings indicate that requiring transgender individuals to use the restroom of their biological sex is not discriminatory.

She pointed to a 2009 ruling by the U.S. Court of Appeals for the Ninth Circuit, which covers much of the western United States. The ruling was interpreted by the Alliance Defending Freedom to mean that school districts could pro­hibit students from using ­opposite-sex restrooms and locker rooms for privacy and safety reasons without violating Title IX.

Last year, the American Civil Liberties Union of Virginia filed a Title IX complaint in Gloucester County, in southeastern Virginia, in a case similar to the one in Stafford. The complaint is pending.

Rebecca K. Glenberg, the ACLU’s legal director, said it was “troubling” that the Stafford School Board acted on the parents’ concerns “without the opportunity for calm reflection or thorough legal analysis or consultation with experts on the subject.”

James Parrish, executive director of Equality Virginia, said his group previously gave to leaders of both parties as a matter of course but no longer does. Parrish laughed off the political spat involving Howell, saying neither he nor Stimpson has shown any interest in protecting LGBT Virginians.

“Let them raise money against each other and fight it out,” he said.