Rouhani's remarks came after the state-run media outlet IRIB reported that Iranian officials had temporarily restricted access to social media apps Instagram and Telegram, which have been used by Iranians to share news about the protests.
"We are a free nation," Rouhani said in his prerecorded speech on state broadcaster IRINN. "And according to the constitution and citizen rights, the people are free to express their criticism and even their protests," he said.
"But," Rouhani continued, "criticism should not be accompanied with violence or vandalizing public property." Rouhani also acknowledged the economic and social hardships some Iranians face.
Protests were ongoing Sunday, the fourth day of demonstrations, according to videos circulating on social media that originated in Tehran and other parts of the country.
Earlier on Sunday, the Iranian Interior Minister Rahmani Fazli issued a stern warning
that protesters who cause public disorder would "pay the price" after the demonstrations reportedly turned deadly.
"The events and occurrences of the last few days have preoccupied, saddened and hurt our beloved people," semi-official news agency ILNA quoted Fazli as saying, before adding "those who destroy public properties, create chaos, lawlessness and insecurity in our society, will be held legally responsible and must answer for their behaviors and pay the price for it."
Social media has been a tool for protesters
Social media has been a vital resource for Iranians participating in the protests -- described as the largest public display of dissent in Iran since the 2009 Green Movement.
While independent media coverage from inside the country has been limited, protesters have taken to apps like Telegram, which offers public channels for users in addition to encrypted messaging, to share information and videos of protests and clashes. Official media outlets have provided few details about the ongoing demonstrations.
Earlier on Sunday, Interior Minister Fazli said the misuse of social networks by some individuals was "causing violence and fear," and that "such behavior will be smashed," according to IRNA.
Telegram's CEO had previously tweeted that Iranian authorities had blocked access to Telegram for "the majority of Iranians" after the company refused to shut down peaceful protesting channels.
Protests turn deadly
Two people were killed Saturday during protests in Doroud city, in the Lorestan province of western Iran, according to semi-official news agency Mehr News.
On Sunday, Mehr News quoted Habibollah Khojastehpour, the deputy governor of Lorestan, as confirming the deaths but denying security forces were to blame.
Several videos circulated on social media showed various people apparently injured during protests in the city. The videos purportedly showed injured people lying on the ground and being carried away from the protest, as well as being treated in a local hospital. In some of the video, gunshots can be heard.
CNN cannot independently verify the authenticity of the video.
One local source told CNN on Saturday that during protests in the city, his family witnessed a mob storming the governor's office and setting it on fire. Protesters were fired upon and five people were shot, the source said.
According to Mehr, Khojastehpour said fire was not directed toward or into the crowds by the military, security or police forces.
"Clashes occurred with individuals who had taken to the streets, heeding calls by the enemies of the system," Khojastehpour is quoted as saying. "The objective was to conclude this gathering peacefully but given the presence of the aforementioned individuals and groups, this tragedy unfortunately occurred that resulted in the killing of two individuals who were present at the clashes."
'Death to the dictator'
In a rare display of public dissent, some protesters directed their ire at Supreme Leader Ayatollah Ali Khamenei, according to some videos on social media. CNN has not independently verified the authenticity of the footage.
In another video also circulating on social media, Iranians can be overheard chanting "We don't want an Islamic Republic" and "Death to the dictator." The video purports to show demonstrators in the western city of Khorramabad.
In addition to these anti-government slogans, chants of "Death to the Revolutionary Guards" can also be heard in another video posted on social media.
CNN is unable to independently verify the authenticity of those videos.
One resident told CNN of witnessing a protester tearing down a poster of Khamenei near Tehran University on Saturday.
In Tehran, protesters have been temporarily arrested for participating in "illegal demonstrations," according to Mohsen Hamadani, Tehran deputy governor in charge of security affairs, as reported by semi-official ILNA.
About 200 people were arrested between Revolution Square and Valiasr Square in Tehran on Saturday, ILNA reported, for "attempting to destroy public property and attack police," according to Ali Azghar Nasserbakt, the deputy commander of Tehran Security. Some have been released, he said, though he didn't provide a specific number.
On Saturday, 80 people were detained in the nearby city of Arak, according to a government official, as reported by Mehr News Agency.
"A number of individuals intended to enter into and damage government locations," the government official, who was not identified by Mehr, is quoted as saying. The official added that protesters were not able to enter the government buildings, "and the city is under control."
Mehr added that at least three people were lightly injured.
US-Iran war of words
President Donald Trump has voiced his support for anti-government protesters in several tweets
throughout the weekend, sparking a war of words with the Iranian government.
"Iran, the Number One State of Sponsored Terror with numerous violations of Human Rights occurring on an hourly basis, has now closed down the Internet so that peaceful demonstrators cannot communicate," he wrote late Sunday. "Not good!"
Contrary to the President's tweet, Iran has not "closed down the Internet," though it has restricted Iranian's access to some social media.
On Saturday, Iranian Foreign Ministry spokesman Bahram Qassemi pushed back against earlier US comments, saying the Iranian people gave no credence to such "opportunistic" remarks by Trump or his administration.
Iranian officials have pointed to foreign intervention as being behind the protests.
During Sunday's televised remarks, Rouhani accused Trump of creating problems for Iranians, saying he had "always been acting against the people from the first day he entered the White House."
"He has been constantly creating problems for us, nonstop and continuously for the Iranian nation," he said.
Relations between Washington and Tehran have long been tense, with the Trump administration critical of what it sees as Iran's growing regional influence
and alleged involvement in conflicts including Yemen
Rouhani won a landslide re-election in May after campaigning largely on social reform. His campaign touted the merits of the 2015 nuclear deal with the United States, the European Union and other partners, a deal rejected by Trump