Iran’s Ayatollah Ali Khamenei paid a condolence visit Friday to the widow of Qassem Soleimani — hours after the supreme leader warned of a “harsh retaliation” against the US for killing his top ­general.

The ayatollah sat next to a framed photograph of the slain commander of the elite Quds Force, a subset of the Islamic Revolutionary Guard Corps, as he consoled the grieving woman in Tehran.

Meanwhile, crowds took to the streets in the capital and other cities to protest Washington’s “crimes” hours after a drone strike took out Soleimani at the airport in Baghdad, Iraq, along with several others.

Chanting “Death to America” and holding up posters of Soleimani, 62, the masses filled the streets of Tehran after Friday prayers.

“Soleimani’s blood spilled, the nation’s outrage against the enemy sparked!” the demonstrators chanted in footage aired by the state-run Islamic Republic News Agency.

The demonstrators, many of them elderly, took part in the processions, some displaying portraits of the supreme leader.

“The axis of any evil is America. The motto of religion and the Koran is death to America!” they yelled in unison. “Oh, leader of our revolution, condolences, condolences.”

In Kerman in southeastern Iran — where Soleimani was born — a giant procession of black-clad mourners chanted religious slogans, according to The Washington Post. Elsewhere a group of men ripped holes out of a US flag before setting it ablaze.

“This was a good move, so that the whole world would realize who the terrorist is. The whole world found that out,” Ali Bakhshi, an elderly cleric, told Agence France-Presse.

“The dear leader of the revolution respond to them [the US] very intelligently and precisely. And the nation of Iran will resist,” he added.

Khamenei warned that the Islamic Republic will hit back at the US for killing Suleimani, calling him the “international face of resistance” and declaring three days of public mourning. He also appointed Brig. Gen. Esmail Ghaani, Suleimani’s deputy, to replace him as head of the Quds Force.

Iranian President Hassan Rouhani called the killing a “heinous crime” and vowed that his country would “take revenge.”

Iran’s Supreme National Security Council also issued a statement threatening retaliation for the strike, saying it had made “appropriate decisions” that would hold Washington responsible for “all of the consequences of this strategic mistake.”

“Severe revenge awaits the criminals who smeared their dirty hands with the pure blood of Gen. Soleimani,” the statement said. “These cowardly acts will boost the will of the Islamic Republic to be more active in its resistance and to bring a swift defeat” to the enemy.

Dozens of green-clad members of the Guards also took part in a mournful procession. “I think America has taken a big risk and will get its response as well,” a Guards member who only gave his surname as Qasemi told AFP.

State news agency IRNA said similar demonstrations broke out in the cities of Arak, Bojnourd, Hamedan, Hormozgan, Sanandaj, Semnan, Shiraz and Yazd.

With Post wires