US-backed forces said they had captured Islamic State's last shred of territory in eastern Syria at Baghouz on Saturday, ending the group's self-proclaimed caliphate after years of fighting.
"Baghouz has been liberated. The military victory against Daesh has been accomplished," Mustafa Bali, a Syrian Democratic Forces (SDF) spokesman, wrote on Twitter, declaring the "total elimination of (the) so-called caliphate".
However, a Reuters journalist at Baghouz said there were still some sounds of shooting and mortar fire.
The final battle lasted weeks as huge numbers of civilians poured out, and for many Kurdish fighters in the SDF, victory was sweeter as it coincided with their "Now Ruz" new year.
Though the defeat of Islamic State in 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.
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 U.S. 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 stolen antiquities financed its agenda, which included slaughtering 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.
Intense air strikes throughout the campaign have levelled entire districts and rights groups have said they killed many civilians, allegations the coalition has often disputed.
A mass grave the SDF discovered 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, often traumatized, residents.
Their fate has befuddled foreign governments, who see them as a security threat and are loath to accede to SDF entreaties to take them back home.
As the fighting progressed, 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 that squalid, 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 in Baghouz in recent weeks long lines of abject, surrendering fighters sat or squatted in a desolate landscape, their dream of world domination in tatters.