U.S. President Donald Trump said Iran's Supreme Leader Ayatollah Ali Khamenei should be very careful about what he says after Khamenei harshly criticized the United States in a Friday prayers sermon in Tehran.

"The so-called 'Supreme Leader' of Iran, who has not been so Supreme lately, had some nasty things to say about the United States and Europe," Trump said in a tweet.

"Their economy is crashing, and their people are suffering. He should be very careful with his words!"

Khamenei struck a defiant tone in his first Friday sermon in Tehran in eight years, calling Trump a "clown" who only pretends to support the Iranian people but will "push a poisonous dagger" into their backs.

Khamenei said the mass funerals for Iran's top general, who was killed in a U.S. airstrike earlier this month, show the Iranian people support the Islamic Republic despite its recent trials. He said the "cowardly" killing of Qassem Soleimani had taken out the most effective commander in the battle against ISIS.

Iranian mourners gather on Jan. 7 around a vehicle carrying the coffin of slain top Gen. Qassem Soleimani during the final stage of funeral processions, in his hometown of Kerman. (Atta Kenare/AFP/Getty Images)

In response, Iran launched a barrage of ballistic missiles targeting U.S. troops in Iraq, without causing serious injuries. Khamenei said the strike had dealt a "blow to America's image" as a superpower. In part of the sermon delivered in Arabic, he said the "real punishment" would be in forcing the U.S. to withdraw from the Middle East.

Downing of Flight PS752 'a bitter accident'

As Iran's Revolutionary Guard braced for an American counterattack that never came, it mistakenly shot down Ukraine International Airlines Flight PS752 shortly after it took off from Tehran's international airport, killing all 176 passengers, including 57 Canadians and dozens of others bound for Canada.

Authorities concealed their role in the tragedy for three days, initially blaming the crash on a technical problem. Their admission of responsibility triggered days of street protests, which security forces dispersed with live ammunition and tear gas.

Khamenei called the shootdown of the plane a "bitter accident" that saddened Iran as much as it made its enemies happy. He said Iran's enemies had seized on the crash to question the Islamic Republic, the Revolutionary Guard and the armed forces.

In this photo released by an official website of the office of the Iranian supreme leader, Khamenei delivers his sermon in the Friday prayers at Imam Khomeini Grand Mosque in Tehran. (Office of The Iranian Supreme Leader/The Associated Press)

He also lashed out at Western countries, saying they are too weak to "bring Iranians to their knees."

He said Britain, France and Germany, which this week triggered a dispute mechanism to try to bring Iran back into compliance with the unravelling 2015 nuclear agreement, were "contemptible" governments and "servants" of the United States.

He said Iran was willing to negotiate, but not with the United States.

Khamenei has held the country's top office since 1989 and has the final say on all major decisions. The 80-year-old leader openly wept at the funeral of Soleimani and vowed "harsh retaliation" against the United States.

Thousands of people attended the Friday prayers, occasionally interrupting his speech by chanting "God is greatest" and "Death to America."

Sanctions trigger economic crisis, protests

Tensions between Iran and the United States have steadily escalated since Trump withdrew the U.S. from Iran's 2015 nuclear deal with world powers, which had imposed restrictions on its nuclear program in exchange for the lifting of international sanctions.

The U.S. has since imposed crippling sanctions on Iran, including its vital oil and gas industry, pushing the country into an economic crisis that has ignited several waves of sporadic, leaderless protests. Trump has openly encouraged the protesters — even tweeting in Farsi — hoping that the protests and the sanctions will bring about fundamental change in a longtime adversary.

After Soleimani was killed, Iran announced it would no longer be bound by the limitations in the nuclear agreement. European countries that have been trying to salvage the deal responded earlier this week by invoking a dispute mechanism that could result in even more sanctions.

Khamenei was always skeptical of the nuclear agreement, arguing the United States could not be trusted. But he allowed President Hassan Rouhani, a relative moderate, to conclude the agreement with President Barack Obama. Since Trump's withdrawal, he has repeatedly said there can be no negotiations with the United States.

Khamenei last delivered a Friday sermon in February 2012, when he called Israel a "cancerous tumour" and vowed to support anyone confronting it. He also warned against any U.S. strikes on Iran over its nuclear program, saying the U.S. would be damaged "10 times over."