The killing of Iranian commander Qasem Soleimani in a US air strike offers a chance for Iran's clerical rulers to rally popular support at an extremely delicate time for the Islamic republic in the wake of unusually fierce protests.

Yet while there has been a genuine outpouring of emotion and anti-American sentiment among Iranians after the killing of Soleimani in Baghdad, the economic hardships that prompted last November's protests are still in place, analysts say.

The protests, which came as US sanctions cripple Iran's economy, were seen as one of the biggest challenges for its leaders since the Islamic Revolution that ousted the shah in 1979 and led to a long-term rupture in US ties.

People have packed the streets in cities across Iran for ceremonies commemorating Soleimani, the mastermind of Iran's operations in Iraq, Syria and Yemen, and seen by some as the de facto number two after supreme leader Ayatollah Ali Khamenei.

"There's a rally around the flag within the regime. Soleimani had good relations with many regime officials from all sides of the political spectrum," said Ariane Tabatabai, an associate political scientist at the Rand Corporation, a policy think tank in California.

Western rights groups have said the protests, which began on November 15 in response to a surprise petrol price hike, were quashed with ferocious force.

Officials in Iran have yet to issue an overall death toll for the days of unrest, but Amnesty International says more than 300 people were killed in the crackdown.

The IMF estimates the Iranian economy contracted 9.5 percent last year after Washington's pullout from the 2015 deal curtailing Tehran's nuclear programme, which was supposed to give sanctions relief.

According to Ray Taykeh, senior fellow for Middle East studies at the Council on Foreign Relations, Iran's economy "has essentially collapsed", with the country now "struggling to meet its domestic budgetary needs".

General Qasem Soleimani was widely popular, famed for suddenly popping up in Middle East conflict zones and credited within Iran with helping defeat Islamic State jihadists in Syria and Iraq General Qasem Soleimani was widely popular, famed for suddenly popping up in Middle East conflict zones and credited within Iran with helping defeat Islamic State jihadists in Syria and Iraq Photo: AFP / ATTA KENARE

But throughout its four-decade history, the Islamic republic has mobilised support by focusing on the twin elements of consistent revolutionary fervour and confrontation with the United States.

The killing of Soleimani -- followed by provocative comments by President Donald Trump that the United States could target Iranian cultural sites if Tehran retaliated -- only fuels this narrative.

There have been massive turnouts at the ceremonies for Soleimani not just in Tehran but also cities like Ahvaz, which saw major unrest in November.

"They (Iran's rulers) have the chance to deflect the blows. Not for a very long time but there will be a popular emotion" said Francois Nicoullaud, a former French ambassador to Tehran. "In the Iranian imagination, he had a great profile as a soldier."

Soleimani was widely popular, famed for suddenly popping up in Middle East conflict zones and credited within the country for helping defeat Islamic State jihadists in Syria and Iraq.

But Tabatabai said that among younger Iranians, Soleimani was the "face of Iranian defence against outside adversaries" but also "the face of an organisation responsible for repression and atrocities".

His killing also comes at a critical political juncture for President Hassan Rouhani, seen as a more moderate figure, who is under pressure from hard-liners just a six weeks ahead of parliamentary elections.

"It's now almost guaranteed that the Iranian parliament will fall into the hands of the most hard-line and militant elements within Iran," said Ali Vaez, Iran analyst for the International Crisis Group (ICG).

For Tehran, the key challenge is how to carry out its pledge to retaliate against the United States, a move that Khamenei is likely to weigh carefully given its impact at home and abroad.

"There will be a moment of introspection. If Iran needs to choose between saving the regime in Tehran versus expanding the regime in the region, I think they will chose saving the regime in Tehran," said Alex Vatanka, senior fellow at the Middle East Institute in Washington.

"The question is what is their calculation," he added.