Haider al-Abadi had declared victory in Fallujah a week ago, but sporadic fighting persisted.
It comes more than two years after the city fell to IS.
The militants still control significant areas in northern and western Iraq, including the country's second-largest city of Mosul.
Dressed in the black fatigues of Iraq's counter terrorism forces, Iraqi Prime Minister Haider al-Abadi visited central Fallujah.
Waving an Iraqi flag, he vowed that the other IS stronghold of Mosul, in the country's north, would also soon be liberated.
"Today our troops liberated Fallujah while at the same time our troops are currently fighting in Mosul. There is no place for ISIS in Iraq, we will chase them everywhere. As we promised to raise the flag high in Fallujah, we will raise it in Mosul soon with the will of our heroes (Security forces). I call on Iraqis to celebrate this day."
Fallujah, just over 60 kilometres west of the capital, Baghdad, was the first city to fall to the militant group in January 2014.
Iraqi forces, backed by allied fighters and US-led coalition warplanes, launched a major assault on the city in May.
Lieutenant General Abdul-Wahab al-Saadi, Commander of the Fallujah operation, paid tribute to the international coalition.
"We would like to extend our thanks to the Iraqi air force and to the (US-led) coalition aircraft which played a big role in this battle. The coalition airstrikes alone left more than 600 extremists killed. Had it not been for the coalition airstrikes, the battle would have taken a long time."
With the operation now over, Interior Ministry spokesman Saad Maan says hundreds of residents have been detained on suspicion of having ties to IS.
"About 1,400 detainees have been arrested according to judicial orders. Most of them have confessed that they have ties to Daesh.''
There's also concern for tens of thousands of civilians.
According to the United Nations, more than 85,000 people fled Fallujah and the surrounding area since the offensive began.
Camps for the displaced run by the government and aid groups have been overwhelmed.
This displaced woman describes her experience.
"We suffered a lot, we were displaced from place to place. All we see is shooting and guns, we escaped without even shoes, walking from street to street."
Share
