Between 20,000 and 30,000 Islamic State (IS) militants remain in Syria and Iraq despite the group's recent losses, according to a United Nations report.

The report says that while many fighters, planners and commanders have been killed, some IS members continue to be fully engaged militarily.

Among them is "a significant component of the many thousands of active foreign terrorist fighters", the report adds.

A "reduced, covert version" of IS could survive in both countries, it warns.

Last month, more than 200 people were killed and around 30 Druze women and children taken captive in an large-scale attack by IS militants in south-west Syria.

In 2014, when IS seized control of large swathes of Syria and Iraq and proclaimed the establishment of a "caliphate", as many as 10 million people lived under its rule.

However, the group was defeated militarily in Iraq and most of Syria during 2017.

Iraqi pro-government forces retook the northern city of Mosul in July 2017, while a US-backed alliance of Kurdish and Arab militias in Syria captured the jihadists' de facto capital of Raqqa three months later.

The UN report says IS still controls small pockets of territory in the eastern Syrian province of Deir al-Zour, where it has been able to extract and sell some oil, and to mount attacks, including across the border with Iraq.

IS does not fully control any territory in Iraq, but it remains active through sleeper cells that have primarily targeted security force bases.

Up to 40,000 foreigners are estimated to have travelled to fight in Syria and Iraq since 2011, but the flow of fighters away from the two countries in the past year has been "lower than expected", according to the report.

The report says IS maintains "significant" affiliates in Afghanistan, Libya, South-East Asia and West Africa.

The rival jihadist group, al-Qaeda, meanwhile retains a stronger presence in areas such as Somalia and Yemen.

The report also notes that there has been a fall in the number of terrorist attacks in Europe since late 2017, but warns that this drop could be temporary as "the underlying drivers of terrorism are all present and perhaps more acute than ever".