Iran has foiled attempts by its foreign enemies to turn legitimate protests into an insurgency to overthrow the Islamic Republic, supreme leader Ayatollah Ali Khamenei said on Tuesday.

Comments on his Twitter feed and in Iranian media underscored the establishment's confidence that it has extinguished the unrest that spread to more than 80 cities in which at least 22 people died since late December.

"Once again, the nation tells the U.S., Britain, and those who seek to overthrow the Islamic Republic of Iran from abroad that 'you've failed, and you will fail in the future, too'," Khamenei tweeted.

The Revolutionary Guards, the military force loyal to Khamenei, said on Sunday security forces had put an end to the unrest that it also said had been whipped up by foreign enemies.

At least 1,000 people have been arrested in the biggest anti-government protests for nearly a decade, with the judiciary saying ringleaders could face the death penalty.

A judiciary official said on Tuesday that a detainee in Arak, a town about 200 km (124 miles) south of Tehran, committed suicide, according to Mizan, the website of the Iranian judiciary.

On Monday, a separate judiciary official announced that a detainee had committed suicide in Tehran's Evin prison.

The reports have raised concerns among human rights activists and some Iranian politicians that detainees may have been killed by security forces while in custody.

"I warn the president and security and judiciary officials to prevent the occurrence of a second Kahrizak," Mahmoud Sadeghi, a parliamentarian, tweeted on Monday. The Kahrizak prison gained notoriety when a handful of detainees were tortured and killed at the site after unrest in 2009.

GRANDSTANDING

Khamenei said U.S. President Donald Trump was grandstanding when he tweeted that protesters were trying "to take back their corrupt government", promising "great support from the United States at the appropriate time!"

The Iranian leader tweeted: "... this man who sits at the head of the White House - although, he seems to be a very unstable man - he must realize that these extreme and psychotic episodes won't be left without a response."

The U.S. House of Representatives voted overwhelmingly, by 415-2, on Wednesday for a resolution supporting the peaceful protests in Iran, criticizing the Iranian government's response and urging targeted sanctions in response to what lawmakers termed Tehran's crackdown.

As well as Washington and London, Khamenei blamed the violence on Israel, exiled dissident group People's Mujahedin of Iran and "a wealthy government" in the Gulf, a probable reference to Iran's regional rival, Saudi Arabia.

In a rare public appearance, the head of Israeli intelligence agency Mossad said the protests were due to Iranian President Hassan Rouhani's failure to improve people's economic or social circumstances, but he said they were unlikely to overthrow the establishment.

"In Iran too, we have eyes and ears," Yossi Cohen told a Finance Ministry conference in Jerusalem.

"One shouldn't develop high hopes, though I would be happy to see a meaningful revolution," he added.

Khamenei has called the protests - which were initially about the economy but soon turned political - "playing with fireworks", but he said citizens had a right to air legitimate concerns, a rare concession by a leader who usually voices clear support for security crackdowns.

"These concerns must be addressed. We must listen, we must hear. We must provide answers within our means," Khamenei was quoted as saying, hinting that not only the government of Rouhani, but his own clerical leadership must also respond.

"I am also responsible. All of us must follow up," Khamenei said.