Iraqi Prime Minister Haider al-Abadi said on Tuesday Islamic State had been defeated from a military perspective but he would only declare final victory after IS militants were routed in the desert.
Iraqi forces on Friday captured the border town of Rawa, the last remaining town under Islamic State control, signalling the collapse of the group's "caliphate" proclaimed after it overran much of Iraq's north and west in 2014.
Securing desert and border areas is what remains in the campaign against Islamic State, military commanders say.
"From a military perspective, we have ended the presence of Daesh in Iraq," Abadi said while addressing a weekly news conference, referring to Islamic State by an Arabic acronym.
"God willing we will announce very soon after the end of the purification operations victory over Daesh in Iraq."
Abadi's comments came as Iranian President Hassan Rouhani declared the end of Islamic State while a senior Iranian military commander thanked the "thousands of martyrs" killed in operations organised by Iran to defeat the militant group in Syria and Iraq.
Political disagreements will pave the way for the Sunni militant group to carry out attacks, however, Abadi said. He was referring to the central Baghdad government's dispute with the semi-autonomous Kurdistan Regional Government over the latter's declaration of independence following a Sept. 25 referendum.
"Any disagreement between political factions will encourage Daesh to carry out terrorist attacks," he said. "I call on our Kurdish brothers to avoid fighting."
Hours before Abadi spoke, at least 23 people were killed and 60 wounded when a suicide bomber set off a truck bomb near a crowded marketplace in the northern Iraqi town of Tuz Khurmatu, south of the oil city of Kirkuk.
Abadi praised a federal court verdict that ruled the Kurdish referendum unconstitutional and called on Kurds not to resort to violence.
Iraq's Supreme Federal Court ruled on Monday that the referendum was unconstitutional and the results void, bolstering Baghdad's hand in a stand-off with the Kurdish region watched closely by neighbouring Turkey and Iran.
"I hail the federal court's decision to void the Kurdish region's referendum," he said.
Kurds voted overwhelmingly to break away from Iraq in the referendum, defying Baghdad and alarming neighbouring Turkey and Iran who have their own Kurdish minorities.
The Iraqi government responded to the referendum by seizing Kurdish-held Kirkuk and other territory disputed between the Kurds and the central government. It also banned direct flights to Kurdistan and demanded control over border crossings.