The frustrations that led to the protests also appear different from the sentiments in 2009.

That year, a wave of demonstrations broke out after the contested election of a hard-line president, Mahmoud Ahmadinejad, and then turned into a wider protest movement against Iran’s leaders.

This time, it is the failure of President Rouhani, a moderate, to deliver greater political changes and economic opportunity, despite the lifting of some of the sanctions against Iran as part of the nuclear deal. Young people are especially angry. The average age of those arrested is under 25, one official said.

The poor economy especially affects Iran’s young people — more than 50 percent of the population is under 30, according to official statistics. Officially, youth unemployment is near 20 percent, but experts say it is really closer to 40 percent.

When the protests started last Thursday in the city of Mashhad, demonstrators chanted slogans about the weak economy.

But as the protests spread, they have taken on a far more political cast. Increasingly, they are being directed at Iran’s entire political establishment. Some demonstrators have even called for the death of Mr. Rouhani and of the supreme leader, Ayatollah Ali Khamenei.

The strength and volatility of the protests have caught Iranian politicians by surprise. Some have denounced them as “riots,” while others have acknowledged that the widespread frustrations at their root can no longer be ignored.

On Monday in Tehran, the atmosphere was tense and security forces were out in large numbers. Protests occurred sporadically, with people shouting slogans and leaving. The day before, protesters in provincial towns tried to storm police stations, military and installations, and also attacked a seminary, state television reported, showing footage of burned cars and fires.