Haider al-Abadi urges all Iraqis to celebrate recapture of Fallujah after more than two years of ISIL rule.

Iraqi Prime Minister Haider al-Abadi has urged all Iraqis to celebrate the recapture of Fallujah during a visit to the city and has vowed the national flag will be raised in Mosul soon.

Iraqi forces took the last positions of the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) in Fallujah on Sunday, establishing full control over one of the group's most emblematic bastions after a month-long operation.

"I call on all Iraqis wherever they are to get out and celebrate," he told Iraqiya state television, standing in front of Fallujah's main hospital with an Iraqi flag around his neck.

Abadi had already declared victory on June 17 after ISIL defences collapsed, with Iraqi forces facing only limited resistance in subsequent clearing operations.

The offensive saw tens of thousands of civilians risk death to flee their homes, leaving Iraq to grapple with a humanitarian crisis as its forces prepare to attack Mosul.

Victory for the security forces in Fallujah came when elite forces retook Jolan, a northwestern neighbourhood where the last ISIL fighters in the city were believed to be holed up.

"It did not take more than two hours for CTS to retake Jolan," said Sabah al-Noman, spokesman for the elite counterterrorism service that has been leading the fight.

"Daesh did not fire a single bullet," he said, using an Arabic acronym for ISIL. "This proves that Daesh was defeated even before our forces got there."

Several other senior military commanders said only small pockets of ISIL fighters remained in the Fallujah area.

Fallujah, in Anbar province, has been under the control of ISIL since January 2014.

The city, about 65km west of the capital Baghdad, was the first city to fall to the group.

Bloody battlefield

During a battle waged by ISIL's predecessor, al-Qaeda in Iraq, Fallujah was the scene of some of the bloodiest urban combat with American forces.

In 2004, more than 100 US troops died and another 1,000 were wounded fighting armed rebels in house-to-house battles.

ISIL fighters still control significant areas in northern and western Iraq, including the country's second-largest city of Mosul.

ISIL declared an Islamic "caliphate" on the territory it holds in Iraq and Syria and at the height of its power was estimated to hold nearly a third of each country.

The latest government offensive began on May 23 and has displaced more than 60,000 people, with most people forced to fend for themselves.

"They have been eating rotten dates and animal feed - and drinking from the river, which is undrinkable" Karl Schembri of the Norwegian Refugee Council earlier said, explaining that the city was already enduring difficult humanitarian conditions.

More than 3.4 million Iraqis have been displaced since January 2014, according to UNHCR, the UN refugee agency.