Iraqi forces on Friday captured the border town of Rawa, the last remaining town under Islamic State control, signaling the collapse of the group's self-proclaimed caliphate.

Rawa's capture marks the end of Islamic State's era of territorial rule over a so-called caliphate that it proclaimed in 2014 across vast swaths of Iraq and Syria.

Iraqi forces "liberated Rawa entirely, and raised the Iraqi flag over its buildings," Lieutenant General Abdul Ameer Rasheed Yarallah said in a statement from the Joint Operations Command.

Syria's army has also declared victory against Islamic State, but last week militants reinfiltrated Albu Kamal, near the border from Iraq, and are still fighting there, as well as in some villages and desert areas nearby.

All the forces fighting Islamic State in both countries expect a new phase of guerrilla warfare, a tactic the militants have already shown themselves capable of.

Prime Minister Haider al-Abadi congratulated Iraq's armed forces and people, saying Rawa was retaken in record time and that Iraq would soon completely defeat Islamic State.

'Total victory is near'

"I congratulate our heroic forces and the Iraqi people on the liberation of Rawa. The success of our forces, in record time and with excellent planning, shows their strength. Our armed forces continue to secure the Jazira and desert area and the Iraqi border. Total victory is near," he said.

A map published by the military showed zero areas under Islamic State control, and a spokesman for the U.S.-led coalition fighting the group in both Iraq and Syria said on Twitter it had "crumbled."

A video issued by the military showed Iraqi forces sending a message to Rawa's residents via radio. Referring to the Sunni militant group by an Arabic acronym, it said, "Daesh has ended for good, and now the age of Iraq begins."

Another showed a convoy of military vehicles sporting Iraqi flags and blasting out the national anthem. State television played patriotic songs and aired footage of troops in Rawa.

"With the liberation of Rawa we can say all the areas in which Daesh is present have been liberated," a military spokesman said.

Iraqi forces' vehicles are seen after the fighters captured Rawa town, the last remaining town under Islamic State control, Nov. 17, 2017.

Iraqi forces will now focus on routing the militants who fled into the desert and exert control over Iraq's borders, the spokesman said.

Rawa borders Syria, whose army seized the last substantial town on the border with Iraq, Albu Kamal.

Albu Kamal shares a border crossing with al-Qaim in Iraq.

The militants lost control of the border crossing earlier this month, dealing a critical blow to the organization, which had long relied on the route to move its fighters and equipment.

The group's leader, Abu Bakr al-Baghdadi, is believed to be hiding in the stretch of desert that runs along the border of both countries.

Shrinking caliphate

Driven this year from its two de facto capitals — Iraq's Mosul and Syria's Raqqa — Islamic State was progressively squeezed into an ever-shrinking pocket of desert, straddling the frontier between the two countries, by enemies that include most regional states and global powers.

In Iraq, Islamic State faced the army and the Shiite paramilitary groups, backed both by the U.S.-led international coalition and by Iran.

Iraq has been carrying out its final campaign to crush the Islamic State caliphate while also mounting a military offensive in the north against the Kurds, who held an independence referendum in September.

However, Islamic State's defeat does not mean civilians are now safe, the International Rescue Committee said. Nearly 3.2 million people are unable or unwilling to return home after years of displacement, and over 11 million need humanitarian assistance, it said.

"Today marks a historic day for the people of Iraq. It is, however, vital that the international community does not view the end of [Islamic State] territorial control as the end of their responsibility to the Iraqi people who have endured years of conflict and face a long, difficult recovery," the group's Iraq country director, Wendy Taeuber, said in a statement.