The self-styled Isis caliphate, which once stretched for thousands of miles and ruled over millions of people, has been declared defeated.

The end for the terrorist state came in the village of Baghouz, in Syria’s eastern Deir ez-Zor province, following a months-long final battle.

“Syrian Democratic Forces declare total elimination of so-called caliphate and 100 per cent territorial defeat of Isis,” said Mustafa Bali, spokesman of the US-backed group. Mr Bali added: “On this unique day, we commemorate thousands of martyrs whose efforts made the victory possible.”

Theresa May praised the “immense courage of the UK military and our allies” following the announcement.

“We will continue to do what is necessary to protect the British people, our Allies and partners from the threat Daesh poses,” the prime minister said.

Timeline of the Isis caliphate Show all 19 1 /19 Timeline of the Isis caliphate Timeline of the Isis caliphate ISIS began as a group by the merging of extremist organisations ISI and al-Nusra in 2013. Following clashes, Syrian rebels captured the ISIS headquarters in Aleppo in January 2014 (pictured) AFP/Getty Timeline of the Isis caliphate Abu Bakr Al-Baghdadi declared the creation of a caliphate in Mosul on 27 June 2014 Timeline of the Isis caliphate Isis conquered the Kurdish towns of Sinjar and Zumar in August 2014, forcing thousands of civilians to flee their homes. Pictured are a group of Yazidi Kurds who have fled Rex Timeline of the Isis caliphate On September 2 2014 Isis released a video depicting the beheading of US journalist Steven Sotloff. On September 13 they released another video showing the execution of British aid worker David Haines Timeline of the Isis caliphate The US launched its first airstrikes against Isis in Syria on 23 September 2014. Here Lt Gen William C Mayville Jnr speaks about the bombing campaign in the wake of the first strikes Getty Timeline of the Isis caliphate Isis militants sit atop a hill planted with their flag in the Syrian town of Kobani on 6 October 2014. They had been advancing on Kobani since mid-September and by now was in control of the city’s entrance and exit points AFP/Getty Timeline of the Isis caliphate Residents of the border village of Alizar keep guard day and night as they wait in fear of mortar fire from Isis who have occupied the nearby city of Kobani Getty Timeline of the Isis caliphate Smoke rises following a US airstrike on Kobani, 28 October 2014 AFP/Getty Timeline of the Isis caliphate YPG fighters raise a flag as they reclaim Kobani on 26 January 2015 VOA Timeline of the Isis caliphate Isis seized the ancient Syrian city of Palmyra on 20 May 2015. This image show the city from above days after its capture by Isis Getty Timeline of the Isis caliphate Kurdish forces are stationed on a hill above the town of Sinjar as smoke rises following US airstrikes on 12 November 2015 AFP/Getty Timeline of the Isis caliphate Kurdish forces enter Sinjar after seizing it from Isis control on 13 November 2015 AFP/Getty Timeline of the Isis caliphate Iraqi government forces make the victory sign as they retake the city of Fallujah from ISIS on 26 June 2016 Getty Timeline of the Isis caliphate Iraqi forces battle with Isis for the city of Mosul on 30 June 2017 AFP/Getty Timeline of the Isis caliphate Members of the Iraqi federal police raise flags in Mosul on 8 July 2017. On the following day, Iraqi prime minister Haider Al Abadi declares victory over Isis in Mosul Getty Timeline of the Isis caliphate Members of Syrian Democratic Forces celebrate in Al-Naim square after taking back the city of Raqqa from Isis. US-backed Syrian forces declare victory over Isis in Raqqa on 20 October 2017 after a four-month long campaign Getty Timeline of the Isis caliphate Female fighters of the Syrian Democratic Forces celebrate in Al-Naim Square after taking back the city of Raqqa from Isis. US-backed Syrian forces declare victory over Isis in Raqqa on 20 October 2017 after a four-month long campaign AFP/Getty Timeline of the Isis caliphate Trucks full of women and children arrive from the last Isis-held areas in Deir ez-Zor, Syria in January 2019 They were among the last civilians to be living in the ISIS caliphate, by this time reduced to just two small villages in Syria’s Deir ez-Zor Richard Hall/The Independent Timeline of the Isis caliphate Zikia Ibrahim, 28, with her two-year-old son and 8-month-old daughter, after fleeing the Isis caliphate, on Saturday 26 January 2019 Richard Hall/The Independent

French President Emmanuel Macron said that “a major danger to our country is now eliminated, yet the threat remains and the fight against terrorist groups must continue.”

Britain and France were junior partners in the US-led coalition that helped turn the tide against Isis when it joined the fight in 2014.

In a later statement, Donald Trump said Washington would “remain vigilant” until the group “is finally defeated wherever it operates”. To “all of the young people on the internet” who felt attracted by Isis’ propaganda, he said: “Think instead about having a great life.”

The last fight was one of the toughest yet. After years of steadily clawing back territory from Isis across northeast Syria, in September the SDF surrounded the last pocket of Isis control in an isolated string of villages along the eastern banks of the Euphrates river.

These hamlets became the last holdout for the group’s most hardened fighters and leaders. With nowhere else to run, many decided to fight to the bitter end, leading to massive casualties on both sides. The SDF said Saturday that it had lost 11,000 fighters over the course of the campaign.

The final advance was slowed by the presence of thousands of civilians. The last few months has seen an exodus from the Baghouz area. Trapped in an ever-shrinking patch of land, they were without food and under constant bombardment. Some 60,000 people filed out of the dwindling enclave, nearly half of whom were surrendering supporters of Isis, including some 5,000 fighters. Many were foreigners from Iraq, Kazakhstan, Russia and even France.

In the end, a small band of Isis fighters were cornered in a tent camp on the edge of Baghouz. Over the course of a few weeks, the camp was largely destroyed by the fighting and intense bombing. It was an ignoble end for caliphate’s citizens, who came in their thousands to join what they thought was a religious paradise.

Isis is likely to remain a potent force in both Iraq and Syria for some time, but the loss of its territory marks a huge military defeat and a blow in morale for the world’s most powerful jihadist group.

The war to defeat Isis brought the bitterest of enemies together and cost tens of thousands of lives.

A young girl pulls her belongings after arriving from the last Isis-held areas in Deir ez-Zor, Syria, on Saturday 26 January (Richard Hall/The Independent)

The Isis caliphate was declared on 29 June, 2014. Isis fighters had just swept across northern Syria and Iraq in a blistering offensive that shocked the world, sending the US-funded Iraqi army fleeing.

Days later, the group’s secretive leader, Abu Bakr al-Baghdadi, emerged from the shadows to declare himself leader of the new Islamic State. In a carefully stage-managed address, he called on Muslims around the world to join his holy war.

“This is a duty on Muslims that has been lost for centuries,” he said from the steps of the al-Nuri Mosque in Mosul.

Thousands of sympathisers and supporters from all over the world travelled to Syria and Iraq, including some 900 Britons. Even those who didn’t fight played an important role. Those “muhajireen” were a powerful recruiting tool for others to join. They glorified life in the caliphate through social media posts, and celebrated violence against non-Muslims and other perceived enemies.

With control over the Syrian city of Raqqa and Iraq’s Mosul, Isis ruled over more than 34,000 square miles. In a short space of time, it managed to create the structure of a functional proto-state, which made billions from exporting oil, taxes, extortion and kidnap.

Isis has become extraordinarily adept at surviving through adversity Charles Lister, senior fellow at the Middle East Institute

From its inception, the state carried out violence on a grand scale. In August 2014, its fighters carried out its most heinous crime.

After overrunning the town of Sinjar in northern Iraq, fighters massacred nearly 10,000 civilians belonging to the Yazidi faith, whose members Isis deemed heretics. Some 7,000 were kidnapped by the group, with thousands of women being taken as sex slaves. Close to half of those women remain unaccounted for. The United Nations later declared those acts a genocide against the Yazidi people.

But Isis atrocities weren’t reserved for any one group – thousands of Shias, Christians and Sunnis were murdered in its reign of terror. Mass graves litter the landscape from Raqqa to Mosul. The true number of Isis victims may never be known.

An SDF fighter hands out bread to women and children after they arrive from Isis-held areas in Deir ez-Zor today (Richard Hall/The Independent)

The group’s barbarity had mobilised the most powerful armies in the world, as well as a mosaic of local forces and fighters. The Yazidi genocide led to the intervention of the US and other nations, who formed a 79-member coalition to defeat the group.

Over the next few years, US airpower was used to devastating effect to force Isis from its strongholds. Arab tribes fought alongside Kurdish leftists in northern Syria. The Kurdish peshmerga coordinated with the Iraqi army to recapture Mosul. Russian and US forces shared intelligence. At the end, Isis found itself surrounded on one side by the Syrian army, and the other by US-backed forces.

In fact, the very summer that Isis declared its caliphate was when the organisation peaked. A turning point came with the battle for the Kurdish Syrian city of Kobani, on the border with Turkey.

In September 2014, Isis laid siege to the city and sent more than 100,000 people fleeing. But People’s Protection Units (YPG), a hitherto relatively unknown Kurdish militia, put up a fierce resistance – backed for the first time by massive aerial support from the newly formed anti-Isis coalition, led by the US. The YPG’s women fighters played a key role in the battle, and others after it. By March 2015, Kobani had been recaptured, and a model for how to defeat the terror group had been formed.

Major battles in Mosul and Raqqa followed the same pattern. Local forces led the fight on the ground, backed by overwhelming air power from the coalition. This method was successful in removing Isis, but it came at a terrible cost.

The coalition launched more than 30,000 airstrikes during Operation Inherent Resolve, laying waste to towns and cities in the process. The coalition conceded responsibility for 1,190 civilian deaths, but the independent monitors put the number much higher. Airwars, a group that monitored civilian casualties caused by the coalition, estimated the true number of deaths could be higher than 11,000.

Female fighters of the Syrian Democratic Forces (SDF) gather during a celebration at the iconic Al-Naim square in Raqqa in October 2017, after retaking the city from IS (Getty) (AFP/Getty)

And still, the fight is not yet over. Even now in the throes of victory, the same fighters who crushed the caliphate are preparing for a different battle against the group. Isis is already morphing back into an insurgent group, one with the capability to cause havoc and death in the areas it used to control.

“Isis is a terrorist organisation that’s existed longer without territory than with it,” said Charles Lister, a senior fellow at the Middle East Institute and author of a book on the jihadist group.

“It’s become extraordinarily adept at surviving through adversity; and its very existence is due almost entirely to underlying dynamics that remain as bad today as they were in years past – in fact, some of those conditions have worsened. To suggest Isis is ‘defeated’ now would be the height of hubris.”

Aghiad al-Kheder, a former resident of Deir ez-Zor and citizen activist who lived under Isis, said he feared the group would be back in the near future.

“This happened before in Iraq. Everyone said the Islamic State had been defeated in 2007, but it returned. They have only been eliminated geographically,” he said. “We have to think about the ideas Isis left behind, and the children who no longer know what is right and what is wrong.”

Not only that, but the massive destruction wrought by the campaign may have helped the group gain more followers, he added.

Support free-thinking journalism and attend Independent events

That threat will not be limited to Iraq and Syria, either. Alex Younger, the head of MI6, said that surviving foreign Isis members seeking to return home will present a major security challenge in the years ahead.

“They are likely to have acquired both the skills and connections that make them potentially very dangerous and also experienced extreme radicalisation,” he said.

“That fact needs to be uppermost in our minds as we approach this admittedly extremely complex and difficult problem. Public safety is the first thing that we will consider.”

One Kurdish commander recently told The Independent that some of his unit are already switching to counter-terrorism tasks in areas retaken from Isis.