Iraqi Prime Minister Haider al-Abadi arrived in Mosul on Sunday and congratulated Iraqi armed forces for driving the extremist militant Islamic State (ISIS) group out of its major stronghold in the country.

Iraqi armed forces, backed by a United States-led coalition, were battling ISIS in Mosul for months. The victory marks the end of the battle that left Iraq's second largest city in ruins, killed hundreds of people and displaced almost a million civilians.

Abadi's office said he was visiting "liberated" Mosul to congratulate his "heroic fighters". However, the Prime Minister later suggested he would only declare victory once final pockets of resistance were cleared.

"Victory is certain, and the (IS) remnants are surrounded... and it is just a matter of time for us to announce the great victory to our people," Abadi said in a statement.

The delay "comes out of my respect and support for our... forces who are continuing the clearing operation," he said.

"There are only one or two pockets of Daesh remnants left," and "the major victory is in hand," the premier added, using an Arabic acronym for ISIS.

Haider al-Abadi
Iraqi Prime Minister Haider al-Abadi, dressed in a black military uniform and cap (R)Reuters

Iraqi troops are reportedly still battling ISIS militants in some of the last areas of resistance, and could be facing guerrilla attacks for weeks.

The prime minister's office said that Abadi met commanders in Mosul and issued a series of orders on "sustaining victories and eliminating the defeated remnants" of ISIS, as well as "establishing security and stability in the liberated city."

Iraqi Prime Minister Haider al-Abadi
Iraqi Prime Minister Haider al-Abadi meets with officers in Mosul, Iraq, July 9, 2017.Reuters

Although most of Mosul has been reclaimed by the Iraqi forces, they still face dangers ahead with ISIS sleeper cells and suicide bombers.

The forces would also need to clear all the houses in the city, which are rigged with explosive traps so that civilians can return to the region.

The battle against ISIS is still a long way to go in Iraq as other cities continue to remain under the group's control.