Fire departments rarely, if ever, hired female firefighters until shortly after the passage of Title VII of the 1964 Civil Rights Act, which prohibited employers from discriminating against women. Brenda Berkman, a retired captain in the New York Fire Department, whose 1978 lawsuit opened the door to women in that department, said that harassment of women could be extreme in those early years — from death threats to putting pornography on their lockers.

“There was this idea that this was a job for men,” Ms. Berkman said. “Why are women ruining our club? Why are they asking to be treated differently? But we weren’t. All women firefighters were asking for was that this workplace be seen by everyone as a job, not a club.”

Female firefighters have grown in numbers over the years but their share of the total work force has declined recently. According to the Bureau of Labor Statistics, women made up just 3.5 percent of all career firefighters in 2017, down from 5.3 percent in 2007. Marc Bendick, an economic researcher who conducted a national study of female firefighters in 2008, said he had found that most departments continued to be hostile work environments for women.

“It wasn’t that the women couldn’t do the jobs or didn’t want the jobs,” he said. “It was what the departments were doing to them.”

Lawsuits have followed. Curtis Varone, a lawyer in Rhode Island whose law practice is concentrated on issues in the fire service and who has a database of such cases, said of approximately 8,500 cases against the service, the most common type by far involves sexual harassment, which is particularly remarkable, he said, given how few women there are in the service.

“It’s a major problem,” he said.

Chief Stanley, who began as a firefighter in 1995, became an advocate for women in the Fairfax County Fire Department after the suicide of Nicole Mittendorff two years ago. Ms. Mittendorff was a firefighter and paramedic who became the target of lewd posts on a Fairfax County message board written by anonymous commenters, some who claimed to be her colleagues.

Chief Stanley has sued for equal treatment before. She was one of the lead plaintiffs in a class-action lawsuit settled in 2006 over a lack of facilities and promotions for women, among other things. Women have sued the department six times for sex discrimination since 2005, and in most of those cases either settled or won.