Iranian officials insisted for decades that the law requiring women to cover their hair and dress modestly was sacrosanct, not even worth discussion. They dismissed the struggle by women who challenged the law as a symptom of Western meddling.

Now, as Iran holds a presidential election this week, the issue of mandatory hijab, as the hair covering is known, has become a hot campaign topic. And all six of the men running, five of them conservative, have sought to distance themselves from the methods of enforcing the law, which include violence, arrests and monetary fines.

“Elections aside, politics aside, under no circumstances should we treat Iranian women with such cruelty,” Mustafa Pourmohammadi, a conservative presidential candidate and cleric with senior roles in intelligence, said in a roundtable discussion on state television last week. He has also said government officials should be punished over the hijab law because it was their duty to educate women about why they should wear hijab, not violently enforce it.

The hijab has long been a symbol of religious identity, but it also has been a political tool in Iran. And women have resisted the law, in different ways, ever since it went into effect after the Islamic Revolution in 1979.

It is unlikely that the law will be annulled, and it remains unclear whether a new president can soften enforcement. Different administrations have adopted looser or stricter approaches to the hijab. Ebrahim Raisi, the president whose death in a helicopter crash in May prompted emergency elections, had imposed some of the harshest crackdowns on women.

Still, some women’s rights activists and analysts in Iran say forcing the issue to the table during elections is in itself an accomplishment. It shows that the “Women, Life, Freedom” movement of civil disobedience, which began nearly two years ago, has become too big to ignore.

Women and girls are walking on the streets, eating in restaurants, going to work and riding public transportation wearing dresses, crop tops and skirts, and leaving their hair uncovered. In doing so, they take great risks: The morality police lurk on street corners to arrest women defying the rules.

Fatemeh Hassani, 42, a sociologist in Tehran, said in a telephone interview that the fact that hijab and morality police had become an election issue showed that women, through their determination and resistance, had been “effective in influencing the country’s domestic policies and forcing the government to recognize their demands for more rights.”

Women represent about half of Iran’s 61 million eligible voters. Although voter apathy is high among critics of the government, opposition to the hijab law and the morality police is no longer confined to them. It has transcended gender, religious and class lines, and now some of the loudest complaints come from religious people and conservatives, the backbone of the government’s constituents.

During a live televised debate Friday on social issues, women and the hijab dominated the four-hour event. The issue has also surfaced in campaign videos that appear to target female voters and rallies in cities around the country.

In Isfahan, video from a rally for one candidate, Dr. Masoud Pezeshkian, showed an 18-year-old girl, her long black hair flowing around her shoulders, taking the mic. She said she represented the young generation and first-time voters, the generation that stands up for its demands, and asked: “Do you have the power to confront the morality police, the hijab monitors and the autonomous security forces?”

Pezeshkian is the lone candidate for the reform faction, which favors more social openness and engagement with the West. He has been the most forceful voice against the mandatory hijab and the morality police, and the only candidate to clearly say he opposes telling anyone how to dress.