Iran's supreme leader Ayatollah Ali Khamenei has said the army can take their fight beyond Iran's borders, responding to the US killing of his country's top military commander and to anti-government unrest at home over the downing of an airliner.

In his first Friday prayers sermon in eight years, Ayatollah Khamenei also told thousands of Iranians who chanted "Death to America!" that European powers could not be trusted in Iran's nuclear standoff with Washington.

Iran's nuclear ambitions have been at the heart of a months-long crisis, which briefly erupted in the last few weeks into tit-for-tat military strikes between Iran and the United States.

"Resistance must continue until the region is completely freed from the enemy's tyranny," Ayatollah Khamenei said, demanding that US troops leave neighbouring Iraq and the wider Middle East.

Washington's withdrawal in 2018 from Tehran's nuclear deal with world powers and the reimposition of US sanctions that have crippled Iran's economy, led to the latest cycle of hostilities between Washington and Tehran, which have been at odds since the 1979 revolution toppled the US-backed shah.

US President Donald Trump ordered the killing in a drone strike on 3 January of General Qassem Soleimani, commander of the Quds Force, a unit of the Revolutionary Guards responsible for expanding Iran's influence abroad.

He built up regional militias that Washington has blamed for attacks on US forces.

Iran responded with missile strikes on US targets in Iraq on 8 January, injuring although not killing US troops.

"The fact that Iran has the power to give such a slap to a world power shows the hand of God," said Ayatollah Khamenei, in a reference to the strikes, adding that the killing of Gen Soleimani showed Washington's "terrorist nature".

The Quds Force "protects oppressed nations across the region," Ayatollah Khamenei said. "They are fighters without borders."

In the tense aftermath of Iran's missile strikes on US targets when Iranian forces expected US reprisals, the Guards' air defences shot down a Ukrainian airliner in error, killing all 176 people on board, mostly Iranians or dual nationals.

It took days for the Guards, which answer directly to Ayatollah Khamenei, to admit their mistake, even though a commander said he had told the authorities about the cause the same day.

The delay sparked protests across Iran, sometimes meeting a violent crackdown.

Mr Trump sent tweets in Farsi and English to support the demonstrators, drawing a sharp response from Ayatollah Khamenei.

"These American clowns who lie and say they are with the Iranian people should see who the Iranian people are," he said in his sermon, telling Iranians to unite and show solidarity by turning out in numbers in a February parliamentary election.

Ayatollah Khamenei called for national unity and said Iran's "enemies" had tried to use the downing of Ukraine International Airlines flight 752 to shift attention from the killing of Gen Soleimani.