Prime Minister Haider al-Abadi on Saturday declared victory in the three-year war by Iraqi forces to expel the Islamic State group that at its height endangered Iraq's very existence.
"Our forces are in complete control of the Iraqi-Syrian border, and I therefore announce the end of the war against Daesh [IS]," Abadi told a conference in Baghdad.
"Our enemy wanted to kill our civilisation, but we have won through our unity and our determination. We have triumphed in little time," he said.
IS seized vast areas north and west of Baghdad in a lightning offensive in 2014.
With Iraq's army and police retreating in disarray at the time, Ayatollah Ali Sistani, spiritual leader of the country's Shia, called for a general mobilisation, leading to the formation of Hashed al-Shaabi paramilitary units.
Iraq's fightback was also launched with the backing of an air campaign waged by a US-led coalition, recapturing town after town from the clutches of the militants in fierce urban warfare.
"I announce the good news: the liberation by Iraqi forces of the whole of the Iraqi-Syrian border," the prime minister told the conference organised by the Iraqi journalists' union.
The group's defeat is a massive turnaround for an organisation that in 2014 ruled over seven million people in a territory as large as Italy encompassing large parts of Syria and nearly a third of Iraq.
On the Syrian side of the border, IS is under massive pressure too.
On Thursday, Russia's defence ministry said its mission in support of the Syrian regime to oust IS fighters had been "accomplished" and the country was "completely liberated".
In the border region, pro-government forces and US-backed Kurdish-led forces are conducting operations to clear IS fighters from the countryside north of the Euphrates valley after ousting them from all Syrian towns.
The head of Iraq's Joint Operations Command set up to fight IS, General Abdel Amir Yarallah, gave an update on Saturday to announce that the desert valley of Al-Jazira was under the control of Iraqi troops and the Hashed all the way from Nineveh province in the north to Anbar in the west.
Federal forces "now control the border with Syria from Al-Walid border crossing to that of Rabia," covering a distance of 435km, he said.
IS retains capacity
Despite the victory announcements, experts have warned that IS retains the capacity as an insurgency group to carry out high-casualty bomb attacks through sleeper cells.
It also retains natural hideouts in the deep gorges of Wadi Hauran, Iraq's longest valley, stretching from the Saudi border up to the Euphrates River and the frontiers with Syria and Jordan.
The fightback in Iraq kicked off with the "liberation" of Tikrit, north of Baghdad, that had been under IS control for nearly 10 months.
The western cities of Ramadi and Fallujah followed in 2016 before the turning point of the recapture of Iraq's second city of Mosul in July this year after a nine-month offensive led by a 30,000-strong federal force.
The operations have involved both Tehran, through Iranian-trained Shia militias in the Hashed al-Shaabi coalition, and Washington as head of the anti-jihadist coalition.
Abadi said the battle for Mosul, which left the city in ruins and thousands of its residents displaced, marked the end of the Islamic State group's "caliphate".
Victory was declared at the end of August in Tal Afar, the last major IS urban stronghold in northern Iraq, before a final military operation launched last month against IS in a vast desert region of western Iraq.