"Today with God's guidance and the resistance of people in the region we can say that this evil has either been lifted from the head of the people or has been reduced," Rouhani said in an address broadcast live on state TV.
"Of course the remnants will continue but the foundation and roots have been destroyed."
Major General Qassem Soleimani, a senior commander of the elite Revolutionary Guards, also said Islamic State had been defeated, in a message sent on Tuesday to Iran's supreme leader which was published on the Guards' news site, Sepah News.
Iranian media have often carried video and pictures of Soleimani, who commands the Quds Force, the branch of the Guards responsible for operations outside Iran, at frontline positions in battles against Islamic State in Iraq and Syria.
The Revolutionary Guards, a powerful military force which also oversees an economic empire worth billions of dollars, has been fighting in support of Syrian president Bashar al-Assad and the central government in Baghdad for several years.
More than a thousand members of the Guards, including senior commanders, have been killed in Syria and Iraq.
The Syrian conflict has entered a new phase with the capture at the weekend by government forces and their allies of Albu Kamal, the last significant town in Syria held by Islamic State, where Soleimani was pictured by Iranian media last week.
Iraqi forces captured the border town of Rawa, the last remaining town there under Islamic State control, on Friday, signalling the collapse of the so-called caliphate it proclaimed in 2014 across vast swathes ofIraqi and Syrian territory.
Most of the forces battling Islamic State in Syria and Iraq have said they expect it to go underground and turn to a guerrilla insurgency using sleeper cells and bombings.
In his address on Tuesday, Rouhani accused the United States and Israel of supporting Islamic State. He also criticized Arab powers in the region and asked why they had not spoken out about civilian deaths in Yemen's conflict.
The foreign ministers of Saudi Arabia and other Arab states criticized Iran and its Lebanese Shi'ite ally Hezbollah at an emergency meeting in Cairo on Sunday, calling for a united front to counter Iranian interference.
Soleimani acknowledged the multinational force Iran has helped organise in the fight against IslamicState and thanked the "thousands of martyrs and wounded Iranian, Iraqi, Syrian, Afghan and Pakistani defenders of the shrine".
He pointed to the "decisive role" played by Hezbollah and the group's leader Seyed Hassan Nasrallah and highlighted the thousands of Iraqi Shi'ite volunteers, known as the Popular Mobilisation Forces, who have fought Islamic State in Iraq.
On websites linked to the Guards, members of the organization killed in Syria and Iraq are praised as protectors of Shi'ite holy sites and labelled "defenders of the shrine".
Rouhani is scheduled to meet Russian President Vladimir Putin and Turkish leader Tayyip Erdogan in Russia on Wednesday to discuss the Syria conflict.
The Revolutionary Guards initially kept quiet about their military role in both Syria and Iraq but have become more outspoken about it as casualties have mounted. They frame their engagement as an existential struggle against the Sunni Muslim fighters of Islamic State, who see Shi'ites, the majority ofIran's population, as apostates.
Last month, U.S. President Donald Trump gave the U.S. Treasury Department authority to impose economic sanctions on Guards members in response to what Washington calls its efforts to destabilize and undermine its opponents in the Middle East.
(Reporting by Babak Dehghanpisheh; Editing by Catherine Evans)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)