An Iranian woman adjusts headscarves on mannequins at the Islamic fashion exhibit in central Tehran on March 1, 2012. The government’s offensive this year has been marked by the stationing of mixed-gender teams of morality police in Tehran’s main squares. (ATTA KENARE/AFP/GETTY IMAGES)

An annual test of wills between Iran’s morality police and women who dress in ways that are deemed unacceptable has begun in cities across the Islamic republic.

But this year, the stakes are unusually high. As Iranian leaders attempt to deflect the public’s attention from economic woes spurred by crushing foreign sanctions, they risk alienating large segments of a society that is already deeply divided.

Mandatory female covering known as hijab has been a defining element of Iran since the Islamic Revolution in 1979. Although the laws regarding proper cover haven’t changed, some women have grown bolder in interpreting the limits of what they can wear, creating a conflict that inevitably flares each summer as temperatures climb.

The government’s offensive this year has been marked by the stationing of mixed-gender teams of morality police in Tehran’s main squares.

In recent weeks, 53 coffee shops and 87 restaurants have been closed in Tehran for serving customers with improper hijab or for other gender-related offenses, such as permitting women to smoke hookah pipes. Concerts have been abruptly canceled because of inappropriate dress and too much contact between male and female fans. Approximately 80 stands at an international food fair were closed last month because, officials said, the women working at them were either breaking hijab rules or wearing too much makeup.

Those arrested face up to two months in prison or even lashing, penalties that have been on the books for years but have rarely been imposed.

The aggressive enforcement and stiff penalties have spawned resentment.

“I felt disrespected and insulted,” said 30-year-old Sahar, who was arrested for wearing sleeves that went only to her forearms. “I’m a grown woman. I can decide what I can wear. I can make these decisions myself.”

But authorities have made the case this year that un-Islamic dress is a matter of national security and a symptom of longtime Western meddling in Iranian affairs. Officials routinely cite the improper wearing of hijab as the cause of a variety of social maladies, from women who marry later in life to those who go into prostitution. The root problem is often blamed on “foreign agents.”

Tehran’s police chief, Ahmad-Reza Radan, this month called support for improper hijab “part of the enemy’s soft war against us.”

In Iran and other Islamic countries, hijab, which means “cover” in Arabic, has come to define a type of dress code for women, the main priority of which is to obscure signs of femininity. In Iran, that has always meant covering women’s hair and much of the body. Traditionally, covering of the head, arms and legs has been strictly enforced. A long jacket, called a manteau, accompanied by a scarf, has been the accepted minimum.

Over the years, however, what passes as hijab has changed, and now a wide range of styles can be seen in any Iranian city — from the black, all-encompassing chador to brightly colored head scarves that barely stay in place.

Manteau and head scarf shops are some of the most successful retailers in Tehran, where women strive to incorporate fashion trends. Skinny jeans with flat shoes are in this year, and on the streets of Tehran, they are hidden in part by the long, loose-fitting manteaus that are all the rage.

Unlike many of Iran’s leaders, President Mahmoud Ahmadinejad has, since 2010, openly promoted greater tolerance, saying that in the vast majority of cases, improper hijab is not a crime. On Monday, Ahmadinejad said that authorities “instead of closing cinemas and restaurants, must give people the right to choose. If people are given choices, they will definitely choose Iranian culture and beliefs.”

The president’s position has led a growing number of his political rivals to attack his stance as anti-revolutionary and pro-Western. Ali Mottahari, a prominent lawmaker and possible candidate to replace Ahmadinejad in 2013, accused the president in May of promoting “sexual intrigue.”

“We must either accept Western perspectives or Islamic ones, and there is no way in between,” he said.

Such arguments may have a certain appeal at a time when Iran is facing the strain of sanctions — imposed by the United States and other foreign powers — aimed at forcing it to halt its uranium enrichment program.

“Harking back to radical roots is a great comforter and proven survival strategy when positions on other, more substantial, issues are less clear cut,” said Rouzbeh Parsi, a research fellow at the European Union Institute for Security Studies who specializes in Iran.

But the practice also risks spurring a backlash. Those arrested say they feel a growing sense of alienation in their own country.

Mahnaz and Mahin, sisters who are 28 and 29 years old, respectively, were recently arrested because Mahin was wearing a jacket that female morality police officers deemed too short.

“They were so rude to us,” said Mahnaz, who, like others, spoke on the condition that her last name not be used. “They told us, ‘If being arrested for having bad hijab bothers you, you should leave. This is an Islamic country, and we don’t want Western-looking people here.’ ”

Finding urban Iranians who support the program to enforce hijab is increasingly difficult. Many women who dress conservatively also find the patrols distasteful.

“Forcing people to dress a certain way is useless and won’t get the results that they want,” said Nafiseh, a 50-year-old mother of three who wears the tent-like chador. “I’m really against it, because these people aren’t really breaking Islamic rules.”

She said she often intervenes in arrests, knowing that, because of her strict adherence to the dress code, she is unlikely to be punished.

Mostafa, a 46-year-old marketing consultant, described how his 16-year-old daughter was arrested in a crowded shopping mall. “They coaxed her into the police van and told her they just wanted to talk to her,” he explained. “Once she was in the van, the whole atmosphere changed, and they said things that made her cry.”

After a brief time in custody, his daughter, Banafshe, was released. “Do you know what her response was to the whole episode?” he asked. “She said, ‘Dad, as soon as I finish high school, I’m leaving this country forever.’ ”