The killings were not apparently coordinated, but the Islamic State group claimed the atrocities in Tunisia and Kuwait, just days before the first anniversary of it declaring a "caliphate" in Iraq and Syria.
"These terrorist acts are contrary to the teachings of Islam," said foreign ministry spokeswoman Marzieh Afkham in Tehran.
In a separate statement she also denounced the attack in a Tunisian hotel that killed 38 people, mostly British tourists.
The incident was aimed at "defacing Islam's image," she said, urging governments of Muslim countries to "take effective measures against acts of terrorism that harm the image and unity of the Muslim world."
In a telephone conversation with his Kuwaiti counterpart, Zarif said such acts were "one of the key threats against countries in the region".