Iranians are free to protest against the government but must not jeopardise security, President Hassan Rouhani has said after four days of demonstrations.
Speaking at a cabinet session, he acknowledged that there were problems that needed to be solved but warned that violence would not be tolerated.
The protests have been the biggest show of dissent since huge rallies in 2009.
There have been clashes in several cities, and Iran has restricted social networks used to organise protests.
The “temporary” restrictions on the apps Telegram and Instagram were imposed to “maintain tranquillity”, state news agency Irib reports.
The protests began in the north-east as an outcry against economic hardship and rising prices, but turned political in many places, with slogans chanted against Supreme Leader Ayatollah Ali Khamenei, Mr Rouhani and Iran’s interventionist foreign policy in the region.
In his latest tweet on the issue, US President Donald Trump said that Iranians were “finally getting wise as to how their money and wealth is being stolen and squandered on terrorism”.
In his first public comments, Mr Rouhani criticised Mr Trump.
“This gentleman in America, who is now trying to sympathise with our nation, appears to have forgotten that he called the Iranian nation terrorists several months ago,” he was reported to have said.
“This man, who is an enemy of the Iranian nation from the top of his head to his very toes, has no right to sympathise with Iranians,” he added.
The Iranian president said that Iranian citizens were “completely free to express their criticism of the government or stage protests… in a way that would lead to the improvement of the country’s conditions”.
He acknowledged grievances over the economic situation, a lack of transparency and corruption but defended his record.
Mr Rouhani added that expressing criticism was completely different from being violent or destroying public property.
Violence flared in many places on Saturday, and videos posted online suggest demonstrations have continued in a dozen or more cities on Sunday.
Small crowds have gathered in the capital Tehran chanting “death to the dictator” and police have used water cannon to disperse protesters at a major intersection – as captured in a video obtained by BBC Persian.
Why are social networks being restricted?
In a tightly controlled media environment, much of the information about the demonstrations has emerged via social media, and platforms like Telegram and Instagram have been used extensively by protesters.
Telegram in particular is very popular in Iran, with more than 50% of the country’s 80m population said to be active on the app.
The company’s CEO Pavel Durov tweeted that Iranian authorities took action after his company refused to shut down “peacefully protesting channels”.
Mr Durov explained in a Telegram post that a major foreign-based opposition channel, Amadnews, was blocked on Saturday by Telegram after it called for violence against police.
He said a new “peaceful channel” – access to which is now being restricted – was set up for hundreds of thousands of their subscribers.
Iranian Communications Minister Mohammad-Javad Azari Jahromi had earlier accused channels like Amadnews of promoting “armed uprising and social unrest”.
Where will the protests lead?
Analysis by Kasra Naji, BBC Persian
There is widespread and seething discontent in Iran where repression is pervasive and economic hardship is getting worse – one BBC Persian investigation has found that on average Iranians have become 15% poorer in the past 10 years.
Protests have remained confined to relatively small pockets of mostly young male demonstrators who are demanding the overthrow of the clerical regime.
They have spread to small towns throughout the country and have the potential to grow in size.
But there is no obvious leadership. Opposition figures have long been silenced or sent into exile.
Some protesters have been calling for the return of the monarchy and the former shah’s son, Reza Pahlavi, who lives in exile in the United States, has issued a statement supporting the demonstrations. But there are signs that he is as much in the dark about where these protests are going as anyone else.
BBC Persian, which broadcasts on TV, on radio and online from London, is banned in Iran – where staff and their families routinely face harassment and questioning from the authorities.
Have security forces cracked down?
There were outbreaks of clashes in several cities on Saturday and two protesters died of gunshot wounds in the western city of Dorud.
The authorities said security forces did not open fire on demonstrators, and blamed the deaths instead on Sunni Muslim extremists and foreign powers.
Iran’s Revolutionary Guards have warned anti-government protesters they will face the nation’s “iron fist” if political unrest continues. Scores of people are reported to have been arrested in recent days, including 200 in Tehran on Saturday night.
The Iranian authorities are blaming anti-revolutionaries and agents of foreign powers.
What happened in 2009?
Mass demonstrations – referred to as the Green Movement – were held by millions of opposition supporters against the disputed election victory of incumbent president Mahmoud Ahmadinejad.
At least 30 people were killed and thousands arrested in the wave of protests, which drew the largest crowds in Iran since the Islamic Revolution in 1979.