In a sharply worded response to United States President Donald Trump, who alleged Iranian involvement in a rare protest at the US embassy compound in Baghdad, Iran's Supreme Leader Ayatollah Ali Khamenei issued an equally strong response - saying Tehran will openly confront any country that threatens its national interests.

Demonstrators who sympathise with or belong to the Iran-backed Hashd al-Shaabi (Popular Mobilisation Forces, or PMF), breached the outer walls of the heavily fortified US embassy compound in the Iraqi capital on Tuesday, setting parts of its perimeter on fire - an angry reaction to deadly US air raids days earlier against Kataib Hezbollah, an Iran-backed militia associated with PMF.

Trump on Tuesday warned he would hold Iran responsible "for lives lost, or damage incurred, at any of our facilities".

On Wednesday, Khamenei said during a public event in Tehran: "For one thing, you are damned wrong because this matter has nothing to do with Iran.

"If Iran decides to confront a country, it will do so openly. But everyone must know that we are strongly committed to the country's interests and we shall not hesitate to intervene and deal a blow to any party who attempts to pose a threat to the country."

Iran's Ministry of Foreign Affairs meanwhile used diplomatic channels to summon a Swiss envoy representing US interests in Tehran, and issued a "strong protest against warmongering statements."

The ministry's statement attempted to distance Iran from events in neighbouring Iraq, saying "Iraq is an independent country".

It also described language by US officials against Iranian influence in Iraq as a "violation of the United Nations Charter".

Mohammad Marandi, head of the North American studies department at the University of Tehran, told Al Jazeera: "Iranians don't take the American threats very seriously because a military confrontation with Iran would not mean a victory for the US.

"The price of any American attack against Iran would be too high, and the cost to the entire region would be even higher."

Marandi argued that the US, having spent "trillions of dollars on the conflict in Iraq, which was a total failure, wants to use Iran as a scapegoat to justify its failure.

"Iranians will not accept to being treated as a scapegoat and Iran is not afraid of the US."

Hussein Royvaran, who teaches international relations at the University of Tehran, told Al Jazeera that Iranians reject Washington's threats against their country because it was the US that "violated Iraqi sovereignty and killed Iraqi members of Hashd al-Shaabi", which he described as an official Iraqi military unit.

He said that the US has "committed a crime" in Iraq and should bear the consequences of its actions, referring to the protest around the US embassy compound - which came to an end on Wednesday as demonstrators left the area.

Royvaran said the US has military bases in Iraq and enjoys political sway in the country, meaning Washington's remarks about Iranian influence should be viewed with caution.

"American officials think that Iran should just protect the American bases in Iraq, something Iran will never do.

"The US is waging an economic war against Iran," he said, in reference to punishing US sanctions against Iran after the US pulled out of a landmark nuclear agreement last year.

Rejecting US references to the Hashd al-Shaabi as "Iranian proxies" or "mercenaries", Marandi said Iran helped establish and arm the paramilitary force in order to defeat ISIL (ISIS), a group that emerged only after the "US destroyed Iraq" following the toppling of Saddam Hussein in 2003.

Follow Ali Younes on Twitter: @ali_reports