Media playback is unsupported on your device Media caption President Obama: "It is still very difficult to detect and prevent small cells of terrorists"

US President Barack Obama says there have been gains against so-called Islamic State in Iraq and Syria but warned the group still poses a threat.

As the jihadist group lost ground, he said, there were signs it was shifting to attacks abroad.

"The possibility of a lone actor or a small cell that kills people is real," he said, adding that networks in the US could be activated.

Mr Obama was giving an update to reporters after a Pentagon meeting.

Separately, he strongly denied that a $400m (£305m) cash payment to Iran was a ransom for the release of American prisoners in January.

The White House provided extensive comments on the issue on Wednesday.

Image copyright Alamy Image caption Western powers have become increasingly concerned at IS's growing presence in Libya

Speaking after the meeting with top military and national security officials on Thursday, Mr Obama said IS was "not invincible".

"In fact, they are inevitably going to be defeated," the president said, predicting that the jihadist group would lose its self-proclaimed capital of Raqqa in Syria, in addition to their stronghold of Mosul in Iraq.

'Bad decisions' warning

Mr Obama also said that IS "has not had a major successful offensive operation in Syria or Iraq in a full year".

While the militant group has been pegged back in those countries, it has carried out or claimed several high-profile attacks this year, such as in Iraq, France, Germany, Bangladesh and several other countries.

President Obama said it was important not to give in to fear.

"Isil can't defeat the United States of America or our Nato partners," he said, using an alternative acronym for IS.

But he warned the US could defeat itself if its leaders made "bad decisions" - like indiscriminately killing civilians or introducing religious tests on who could enter the country.

"Those kinds of strategies can end up backfiring because in order for us to ultimately win this fight we cannot frame this as a clash of civilisations between the West and Islam," he said.

"That plays exactly into the hands of Isil and the perverse interpretations of Islam that they are putting forward."

The US recently stepped up its efforts against IS, bombing one of the group's strongholds in Libya on Monday after a request by the UN-backed government.

Western powers have become increasingly concerned at IS's growing presence in Libya.