In supporting recent anti-government protests in Iran, both Iranian hardliners and the US State Department may want to be careful what they wish for. Not only are the protests unlikely to spark the kind of change either of the two adversaries may be hoping for, they also are refusing to stick to the different scripts the Trump administration and opponents of Iranian President Hassan Rouhani read into them.

For Iranian hardliners, the joker in the pack is what US President Donald J. Trump decides in January to do with the 2015 international agreement that put curbs on Iran’s nuclear program. Mr. Trump will have to again choose whether to certify Iranian compliance as well as extend the temporary waiver of US sanctions on Iran. In October, Mr. Trump refused to certify and threatened to pull out of the agreement if Congress failed to address the agreement’s perceived shortcomings.

Members of Congress have been trying to draft legislation that would give Mr. Trump a face-saving way of maintaining the agreement by claiming that Iranian compliance ensures includes acceptance of restrictions on the country’s ballistic missile program and support of regional proxies. It was not clear whether Washington’s deeply polarized politics would allow for a meeting of the minds of Republicans and Democrats. Iranian hardliners would be strengthened if Mr. Trump failed to maintain US adherence to the agreement and would likely see it as a US breach of the accord.

In a statement condemning the arrests of protesters, State Department spokeswoman Heather Nauer projected the demonstrations as a bid to change Iranian politics. She urged “all nations to support the Iranian people and their demands for basic rights and an end to corruption.” In a reflection of a strand of thinking in Washington that is looking for ways change the regime in Iran, Ms. Nauert quoted US Secretary of State Rex Tillerson as telling Congress that the Trump administration supports “those elements inside of Iran that would lead to a peaceful transition of the government.”

For his part, Mr. Trump tweeted that the “Iranian govt should respect their people’s rights, including right to express themselves. The world is watching!”

Mr. Trump and Ms. Nauert appeared oblivious to the fact that unlike the 2009 mass protests against alleged fraud in presidential elections, the largest since the 1979 toppling of the Shah that were dubbed a Green revolution and brutally squashed, this month’s demonstrations may have been in part prompted by a hard-line effort to exploit widespread discontent to undermine Mr. Rouhani.

If so, Iranian hardliners may be overestimating their ability to ensure that the protesters in a host of Iranian towns and cities, whose numbers range from several hundred to a few thousand, restrict themselves to taking the government to task on economic policy, particularly price hikes and fraudulent financial schemes that have deprived victims of their savings.

Various of the protests have turned into opposition to the very system hard-liners are seeking to defend by demanding a release of political prisoners and the shouting of slogans some reminiscent of the 2009 demonstrations, like ‘Death to the Dictator,’ ‘Leave Syria Alone, Do Something for Us,’ ‘You Are Using Religion as a Tool, You Have Ruined the People,’ and ‘What a mistake we made, by taking part in the revolution,’ to ‘Reza Shah, Bless Your Soul,’ a reference to the founder of the toppled Pahlavi dynasty.

No doubt, the protests reflect widespread grievances, particularly among the Islamic republic’s working and lower middle classes. Expectations that the benefits of the lifting of crippling international sanctions as part of the nuclear agreement would trickle down have so far been dashed. Many criticized on social media a widely debated new government budget that cut social spending but maintained allocations for religious and revolutionary institutions. Many also objected to a hiking of the exit tax that Iranians pay to travel abroad.

The Iranian economy has since the lifting of sanctions emerged from recession, but businesses still suffer a lack of investment while the official unemployment rate has increased by 1.4 percent to 12.7 percent despite economic growth. The government’s policy of allowing Iran’s currency to devalue has fuelled inflation and driven up prices of basic goods like eggs that recently rose by 40 percent.

Nonetheless, the anti-systemic nature of some of the protesters’ slogans speaks to the fact that popular grievances are not purely economic. Many question the government’s investment of billions of dollars in struggles in places like Syria and Yemen as part of its bid to enhance the Islamic republic’s regional position and compete with Saudi Arabia for regional dominance – a policy supported by the hardliners. They feel that the funds could be better employed to improve the economy.

The first protests in the latest round of demonstrations erupted on Friday in Mashhad, Iran’s second largest city, that is home to conservative cleric Ebrahim Raisi, who was Mr. Rouhani’s main challenger in last May’s presidential election. Mashhad is also home to Mr. Raisi’s father-in-law,Ayatollah Ahmad Alamolhoda, a hard-line Friday prayer leader and former prosecutor general and an opponent of Mr. Rouhani’s cautious loosening of strict social mores and encouragement of greater cultural space.

Mr. Alamolhoda charged that the anti-regime slogans came from a small group that was trying to disrupt the protest. The protests erupted almost to the day on the eighth anniversary of the Green Revolution. The latest round built on weeks of smaller protests focused on issues ranging from unpaid wages to bank fraud and embezzlement to environmental issues that appeared to have no connection to any one political group in Iran.

Protesters in Mashhad took to the streets a day after the police chief in the capital Tehran announced that women would no longer be detained or prosecuted for failing to observe strict dress codes imposed immediately after the 1979 revolution. The police chief said violators of the code would receive counselling instead. Younger, more liberal women have long been pushing the envelope on rules that obliged them to cover their hair and wear long, loose garments.

It was not immediately clear what prompted the policy change. Domestic pressure was certainly one driver, but so may have been a desire to compete with Saudi Arabia whose crown prince, Mohammed bin Salman, has grabbed headlines with lifting social and cultural restrictions with measures like a lifting of the ban on women’s driving and creating an entertainment sector.

Iranian-American poet and journalist Roya Hakakian argued in a recent op-ed that Iranian and Saudi women had benefited from “competition between the two regimes to earn the mantle of the modern moderate Islamic alternative.”

A litmus test of Ms. Hakakian’s assertion may be whether Iran follows Saudi Arabia in lifting a ban on women attending male sporting events. An Iranian sports scholar said in a private exchange with this writer that individual women had slipped into soccer matches in Tehran in recent days dressed up as men. A .

The Trump administration’s emphasis on the anti-systemic nature of some of the protests and the hardliners loss of control of demonstrations that they allegedly hoped would focus solely on squeezing Mr. Rouhani takes on added significance with the fate of the nuclear accord hanging in the balance. Hardliners have long opposed the deal because it restricts Iran’s military capability, threatens the vested interests of the Revolutionary Guards and other hardliners, and has not produced expected economic benefits.

The anti-government protests may well constitute a hard-line effort to set the stage for a potential confrontation with the US. If so, protesters have so far not followed the script. The protests, while spreading across the country, have failed to mushroom into truly mass demonstrations and could well turn as much on the hardliners as they target Mr. Rouhani.

By the same token, a US pull-out from the nuclear agreement could fuel increasing nationalist sentiment in Iran that could prove to be a double-edged sword, particularly for Iranian hardliners.

Revolutionary Guard media personnel gathered in 2011 to discuss the waning appeal to Iranian youth of the hard-liners’ religious rhetoric and opted for nationalism as a way of bridging the gaps in society that had become evident in the 2009 protests.

“The youngest generation in our country doesn’t understand our religious language anymore. We’re wasting our time with the things we make. They don’t care about it. That’s why so many of them were in the streets protesting against our system,” a Guards captain told the gathering.

If the protests in recent days prove anything, it is that the nationalism fostered by the Guards and other arms of the government could well take off in unintended directions. That may unintentionally serve US policy goals. It could also spark a much harsher crackdown and a solidifying of hard-line power.