BAGHDAD - The Iraqi army retook the last town in the country still held by the Islamic State group on Friday as the militants' self-proclaimed "caliphate" faced collapse on both sides of the border with Syria.

The lightning recapture of the small Euphrates valley town of Rawa in an offensive launched at dawn came as the militants were also under attack for a second day in the last town they still hold in Syria, Albu Kamal just over the frontier.

The Islamic State group (IS) has lost 95 percent of the cross-border "caliphate" it declared in Iraq and Syria in 2014, the US-led coalition fighting it said on Wednesday.

Its losses include all of its major bastions, virtually confining it to pockets of countryside.

Government troops and paramilitary units "liberated the whole of Rawa and raised the Iraqi flag on all of its official buildings," General Abdelamir Yarallah of Iraq's Joint Operations Command (JOC) said in a statement.

Prime Minister Haider al-Abadi hailed the town's "liberation in record time" and said troops would now "conduct search operations in the desert to secure the border with Syria." "Militarily, IS has been defeated but we are going to hunt down its remnants to eradicate its presence," said JOC spokesman General Yahya Rassoul.

Iraqi IS specialist Hisham al-Hashemi said that after their loss of Rawa, the militants no longer exercised any real military or administrative power.

"What has been liberated are the populated areas with demarcated boundaries," Hashemi said.

"But the seasonal river valleys, the oases, the empty expanses of desert which make up around four percent of Iraqi territory are still in the hands of IS."

Rawa was bypassed in an offensive by the Iraqi army that resulted in the recapture of the strategically important border town of Al-Qaim earlier this month.

The stretch of Euphrates valley abutting the border with Syria has long been a bastion of Arab insurgency, first against US-led troops after the invasion of 2003 and then against the government in Baghdad. The porous frontier became a magnet for foreign fighters entering Iraq from Syria, which Baghdad accused of turning a blind eye, and a key smuggling route for arms and illicit goods. US-led troops carried out repeated operations with code names like Matador and Steel Curtain in 2005 to flush out Al-Qaeda militants.

The region swiftly fell to IS when its fighters swept through the Arab heartland north and west of Baghdad in 2014 before proclaiming its "caliphate".

The militants once controlled a territory the size of Britain but they have successively lost all their key strongholds, including Raqa in Syria and Mosul in Iraq.

"The days of the fake caliphate are now numbered," the US envoy to the coalition Brett McGurk tweeted on Friday.

Over the border in Syria, IS still holds around 25 percent of the countryside of Deir Ezzor province but is under attack not only by government forces but also by US-backed Kurdish-led fighters.

In the border town of Albu Kamal, the Syrian army was battling IS fighters who mounted a surprise counterattack last week, pushing out government forces who had retaken it last month.

The Syrian Observatory for Human Rights, a Britain-based monitor of the war, said the new army offensive had successfully penetrated the town, with troops backed by Russian air strikes advancing from the west, east and south.

With the militants' dreams of statehood lying in tatters following the battlefield defeats, Western attention is increasingly pivoting to trying to block foreign fighters from returning home to carry out attacks.