ISTANBUL — Iran's supreme leader used a rare public sermon Friday to rally Iranians and reclaim the official narrative after an unprecedented confrontation with the United States and the downing of a passenger plane, which sparked days of anti-government protests.

Addressing tens of thousands of worshipers at the Grand Mosalla mosque in Tehran, Ayatollah Ali Khamenei, Iran's top political and religious authority, said the country had passed through an "extraordinary" two weeks, beginning with the U.S. drone strike that killed Maj. Gen. Qasem Soleimani, commander of the elite Quds Force.

“These are turning points, historical days. The Iranian people are resilient,” Khamenei said amid anti-American chants, as the 80-year-old cleric delivered his first public sermon in eight years.

His appearance was a sign of how much recent events have rocked Iran and of the government’s determination to reassert its role as a steady steward for a powerful nation, which is under fire at home and abroad.

The death of Soleimani, the country’s most powerful military figure, prompted a massive outpouring of grief among Iranians, followed by an Iranian ballistic missile strike on two bases in Iraq hosting U.S. forces. But in the immediate wake of that missile attack, Iran’s Islamic Revolutionary Guard Corps accidentally shot down a Ukrainian passenger plane near Tehran, killing all 176 aboard, and the Iranian street turned swiftly against the government, accusing it of egregious incompetence and of covering up its guilt.

At the mosque, worshipers filled the interior and surrounding courtyard, and banners with Soleimani’s image were draped from balconies, according to images shown on state television. Khameini’s appearance had been heavily promoted in advance in Iranian media, and many of those attending were transported to Tehran from outer provinces.

“For a nation to have the ability to slap the face of the world’s bully, this shows the power of God,” Khamenei said, referring to the ballistic missile attack. “It was a blow to the United States militarily,” he added. “But what matters more is that it was a blow to America’s superpower image. This blow was the strongest of all.”

He also had harsh words for European countries, after Britain, France and Germany this week formally launched a negotiation process that could reimpose U.N. sanctions on Iran and lead to the collapse of the nuclear deal it signed with world powers. The 2015 agreement had curbed Iran’s atomic energy activities in exchange for major sanctions relief.

Khamenei criticized the three countries as “U.S. puppets” and warned against trusting European negotiators. “They cover their cast-iron hand with a velvet glove,” he said.

“We are not against negotiations with others — except for the United States — but not from a point of weakness, but instead from a point of strength,” he said.

“Thank God we are strong and will get even stronger,” he declared. “The people of Iran should remain united and resilient and work hard. Then, the Iranians will become a nation where enemies won’t even dare to threaten us.”

But while he struck a defiant pose toward the outside world, the primary audience for his fiery remarks appeared to be domestic.

The Iranian economy is struggling badly, largely as the result of tough sanctions imposed on the country by the Trump administration after it withdrew the United States in 2018 from the nuclear deal. The World Bank expects the economy to shrink 8.7 percent this year. In November, Iran was swept by nationwide protests, initially prompted by cuts in fuel subsidies, and security forces responded with a bloody crackdown that human rights groups say killed at least 200 people.

That public dismay reignited after the downing of the passenger jet. For days, Iranian officials denied that Ukraine International Airlines Flight 752 had been shot down shortly after takeoff from Tehran’s Imam Khomeini International Airport on Jan. 8. But then, three days later, the general staff of Iran’s armed forces said the Islamic Revolutionary Guard Corps downed the plane after mistaking it for a hostile aircraft. Journalists working for state media in Iran resigned in protest, and officials and politicians issued public apologies.

In his sermon, Khamenei called the downing of the plane a “bitter incident” and said measures should be taken to prevent such a disaster from happening again. He thanked the Revolutionary Guard for “offering explanations” to the public.

But in downplaying the recent unrest, Khamenei portrayed the protests against the government as staged by “hundreds” of misguided youths, as well as others who just “do what the enemy wants them to do.”

He contrasted most demonstrations of the past few days with the crowds of people who mourned Soleimani’s death, specifically admonishing protesters who had been filmed tearing down posters and billboards with Soleimani’s picture.

“Those people who desecrated the image of our commander — are they the people of Iran?” he asked. “Or are the people of Iran the millions that you saw in the streets?”

On Friday evening, President Trump tweeted: “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. Their economy is crashing, and their people are suffering. He should be very careful with his words!”

Earlier in the day, the Trump administration’s special envoy for Iran dismissed Khamenei’s remarks as “standard talking points for the regime.” Speaking to reporters at the State Department, Brian Hook said the country is facing the worst diplomatic, political and economic crisis in the four decades since the 1979 revolution.

“President Trump is standing up to them in ways that have no historic precedent,” Hook said. “The regime doesn’t like it. And so we’re not surprised to see the threats that the supreme leader makes.”

Hook predicted that the squeeze on oil exports from U.S. sanctions would fuel hyperinflation and cause Iran’s economy to contract by as much as 14 percent this year.

In his sermon, Khamenei said Iran should work to revive its economy, saying that the nation’s “dependence on oil needs to come to an end.”

Delivering the weekly sermon in Tehran is a task usually reserved for one of Khamenei’s loyal Shiite Muslim clerics. The last time the aging leader spoke at Friday prayers was in 2012.

At the time, Iran was under growing economic pressure due to international sanctions imposed because of its uranium-enrichment program.