The so-called Islamic State has been defeated at its final shred of territory of Baghouz in Syria, the US-backed Syrian Democratic Forces has said, announcing the end of its self-declared "caliphate" that once spanned a third of Iraq and Syria.
The SDF declared the "total elimination of (the) so-called caliphate", Mustafa Bali, head of the SDF media office, wrote on Twitter.
"Baghouz has been liberated. The military victory against Daesh has been accomplished," he wrote.
The SDF has been battling to capture Baghouz at the Iraqi border for weeks.
We need your consent to load this rte-player contentWe use rte-player to manage extra content that can set cookies on your device and collect data about your activity. Please review their details and accept them to load the content.Manage Preferences
Daesh is an Arabic acronym for Islamic State.
"We renew our pledge to continue the war and to pursue their remnants until their complete elimination," he wrote.
Though the defeat of Islamic State at Baghouz ends the group's grip over the jihadist quasi-state straddling Syria and Iraq that it declared in 2014, it remains a threat.
Some of its fighters still hold out in Syria's remote central desert and in Iraqi cities they have slipped into the shadows, staging sudden shootings or kidnappings and awaiting a chance to rise again.
The United States believes the group's leader, Abu Bakr al-Baghdadi, is in Iraq.
He stood at the pulpit of the great medieval mosque in Mosul in 2014 to declare himself caliph, sovereign over all Muslims.
Further afield, jihadists in Afghanistan, Nigeria and elsewhere have shown no sign of recanting their allegiance to Islamic State, and intelligence services say its devotees in the West might plot new attacks.
The Syrian ambassador to the United Nations, Bashar Ja'afari, said on Friday Islamic State was not yet finished in Syria, adding that it was the Damascus government backed by Russia and Iran that was genuinely battling it, not the United States.
Still, the fall of Baghouz is a big milestone in a fight against the jihadist group waged by numerous local and global forces - some of them sworn enemies - over more than four years.
It also marks a big moment in Syria's eight-year war, wiping out the territory of one of the main contestants, with the rest split between President Bashar al-Assad, Turkey-backed rebels and the Kurdish-led SDF.
Assad and his Iranian allies have sworn to recapture all Syria, and Turkey has threatened to drive out the SDF, which it sees as a terrorist group, by force.
The continued presence of US troops in northeast Syria might avert this.
Islamic State originated as an al Qaeda faction in Iraq, but it took advantage of Syria's civil war to seize land there and split from the global jihadist organisation.
In 2014, it suddenly grabbed Iraq's Mosul, one of the region's great historic cities, as well as Syria's Raqqa, and swathes of land each side of the border.
It declared an end to modern countries and called on supporters to leave their homes and join the jihadist utopia it claimed to be erecting, trumpeting its currency, flag, passports and military parades.
Oil production, extortion and antiquities smuggling financed its agenda, which included the slaughter of some minorities, public slave auctions of captured women, grotesque punishments for minor crimes and the choreographed killing of hostages.
Those excesses brought an array of forces against it, forcing it from Mosul and Raqqa in a year of heavy defeats in 2017 and driving it, eventually, down the Euphrates to Baghouz.
Over the past two months some 60,000 people poured out of that dwindling enclave, fleeing SDF bombardment and a shortage of food so severe that some said they were reduced to cooking grass.
A mass grave the SDF discovered there last month showed there were other dangers in the enclave, though it has released no details on the identities of the victims or how they died.
Civilians made up more than half the people leaving Baghouz, the SDF said, including Islamic State victims such as women from the Iraqi Yazidi sect whom the jihadists had sexually enslaved.
Thousands of the group's unbending supporters also abandoned the enclave while still vowing their allegiance to a ruined caliphate and showing no remorse for its victims.
At displacement camps in northeast Syria where they were sent by the SDF, the hardliners, including many foreign women who came to Syria and Iraq to marry jihadists, had to be kept away from other residents.
As the fighting progressed in recent weeks, the convoys of trucks from Baghouz started to include hundreds, and then thousands, of surrendering jihadist fighters, many hobbling from their wounds.
The SDF said it captured hundreds more in recent weeks who tried to slip through its cordon and escape into Iraq or across the Euphrates and into the Syrian desert.
At the end, they were besieged in a tiny camp full of rusting vehicles and makeshift shelters, pinned against the Euphrates and overlooked by hills held by the SDF.
Islamic State released video from inside the shell-pounded enclave, showing its last fighters still shooting at the SDF as smoke billowed overhead.
It was an attempt to shape the narrative of its defeat, portraying it as a heroic last stand against overwhelming odds and a call to arms for future jihadists.
But the footage shown by the SDF in recent weeks was of long lines of abject, surrendering fighters, sitting or squatting in a desolate landscape, their dreams dashed.