TEHRAN, Iran — Two protesters taking part in demonstrations roiling Iran were killed at a rally overnight, authorities said Sunday, as the government blamed "foreign agents" for the deaths and partly blocked access to a popular messaging app used by activists.

The demonstrations, which began Thursday over the economic woes plaguing Iran, appear to be the largest to strike the Islamic Republic since the protests that followed the country's disputed 2009 presidential election.

They were fanned in part by messages sent on the Telegram messaging app, which authorities partly blocked Sunday along with Instagram.

"Those who damage public property, disrupt order and break the law must be responsible for their behavior and pay the price," Interior Minister Abdolreza Rahmani Fazli told state television Sunday.

Later Sunday, President Hassan Rouhani made his first statement since the unrest began, saying people have the right to protest but urging them to do so peacefully.

"Criticism and protest is the people's right; it must solve the problems of the country and improve people's lives," he said. "It is different from violence and destruction of public property."

U.S. President Donald Trump, whose travel bans blocked Iranians from getting U.S. visas, tweeted out his support for the protests Sunday morning after being rebuked by Iran's Foreign Ministry for similar comments on Saturday.

Big protests in Iran. The people are finally getting wise as to how their money and wealth is being stolen and squandered on terrorism. Looks like they will not take it any longer. The USA is watching very closely for human rights violations! — Donald J. Trump (@realDonaldTrump) December 31, 2017

Rouhani, in breaking his silence Sunday, also rebuffed Trump.

Related: Trump's 'America First' policy has isolated U.S. from world leaders

"Government and people solve problems together. One who calls the Iranian nation a terrorist does not have the right of compassion for our people," Rouhani said.

Hours later, Trump tweeted again, calling Iran "the Number One State of Sponsored Terror" and criticizing the country for cutting off access to the Internet. "Not good!" he said.

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. Not good! — Donald J. Trump (@realDonaldTrump) December 31, 2017

It's unclear what effect Trump's support for the protests would have. Iranians are already largely skeptical over his refusal to re-certify the 2015 nuclear deal, while Iran's government has often used comments by U.S. officials to dismiss protests as a sign of foreign interference in its internal politics.

"The people of Iran give no value and credit to Trump," Foreign Ministry spokesman Bahram Ghasemi said Saturday. "The powerful people of Iran don't waste their time with opportunist and meddlesome slogans of American officials."

Iranian President Hassan Rouhani at a cabinet meeting in Tehran on Sunday. Iranian Presidency handout / AFP - Getty Images

Thousands have taken to the streets across Iran, beginning on Thursday in Mashhad, the country's second-largest city and a holy site for Shiite pilgrims.

What started out as a provincial demonstration over the economy appears to have quickly transformed into something more political, with slogans shifting from complaints about the prices of everyday goods to calls for the ruling establishment to be brought down.

The demonstrations spread to the capital, Tehran, on Saturday night, with hundreds of protesters gathering in various squares chanting slogans against the clerical elite and tearing down posters. Meanwhile, social media video appeared to show students inside Tehran University chanting anti-government slogans and clashing with police as they tried to exit the campus.

Earlier Saturday, hard-liners rallied across the country to support Iran's supreme leader, Ayatollah Ali Khamenei, and others in planned demonstrations of support for the regime.

Iranian students clash with riot police during an anti-government protest around Tehran University on Saturday. EPA

In the city of Doroud, in the west of the country, two protesters were killed at an unauthorized rally, said Habibollah Khojastepour, the security deputy of Iran's western Lorestan province. Municipal buildings and banks were also looted, and a police motorcycle was set alight.

Videos on social media purported to show the protesters shot dead by government security forces. But Khojastepour denied that police fired the shots, blaming terrorists and foreign agents.

"We have found evidence of enemies of the revolution ... and foreign agents in this clash," he said on state television Sunday.

NBC News could not verify the videos or details of the shooting.

Many in Iran are learning about the protests and sharing images of them through Telegram, an app popular among the country's 80 million people. On Saturday, Telegram shut down one channel on the service over Iranian allegations that it encouraged violence.

Internet connectivity has also been cut or slowed down dramatically, apparently in an attempt to stop activists from organizing gatherings or posting videos of demonstrations.

The price for public disorder in Iran can be very high. Protesters convicted during the 2009 election were handed down harsh sentences and heavy fines. Authorities said several people who were chanting anti-government slogans and damaging public property were arrested Saturday night in Tehran.

Warnings that civil disobedience won't be tolerated and the fact that social media is being blocked suggests authorities may be preparing to crack down if people return to the streets Sunday evening.

There have nonetheless been calls for more protests, and if people do come out and the clampdown is indeed severe, it remains to be seen whether that would encourage protesters to dig in deeper or scare them off.

The next few days may therefore be critical in determining where this movement is headed, as many in Iran continue to try to understand it.

Within Iran's splintered political system, different factions held one another accountable for the unrest, with hard-liners blaming Rouhani and reformists blaming religious hard-liners. On both sides of the political divide, politicians and clerics said the people had legitimate concerns, but those same people are also saying the protest bears the hallmarks of seditionists and foreign enemies.

Demonstrators protest against Iran's weak economy Saturday in Tehran. AP

Although the protests are widespread, they seem to be smaller than those in 2009.

Unlike the 2009 protests, the crowds aren't chanting the names of the leaders of the so-called green movement or wearing green bracelets in a display of support for reforms, something that had become commonplace in Iran in the years since. In fact, the activists, who appear more emboldened, radical and provocative than in the past, don't appear to be chanting for any leader.

It's expected that the longer the protests go on, the harder security forces will crack down. In many of the videos circulating on social media, the police appear, so far, to have mostly exercised restraint.

There has also been little evidence of the presence of the Revolutionary Guard, but that could change in the coming days.

Iran's economy has improved since Rouhani's government struck the 2015 nuclear deal with world powers, which saw Iran limit its enrichment of uranium in exchange for the end of some of the international sanctions that crippled its economy. Tehran now sells its oil on the global market and has signed deals for tens of billions of dollars of Western aircraft.

That improvement hasn't reached the average Iranian, however. Unemployment remains high. Official inflation has crept up to 10 percent again. A recent increase in egg and poultry prices, by as much as 40 percent, which a government spokesman has blamed on a cull over avian flu fears, appears to have been the spark for the protests.