President Donald Trump said in an interview on Tuesday that ISIS had been defeated.

He's made similar statements before, but military officials have been more circumspect.

While ISIS has lost the territory it once controlled, the group remains a potent terror threat that can strike globally.

President Donald Trump told the Associated Press in a wide-ranging interview on Tuesday that ISIS, the terrorist group that swept over Iraq and Syria in 2014, has been defeated.

US military leaders have said the group has been rolled back and denied control of territory, but they've stopped short of pronouncements like Trump's and noted that coalition forces are still fighting them in their last strongholds.

Asked why more US troops are now abroad in Afghanistan, the Middle East, and Africa, despite Trump's campaign pledges to bring troops home, the president said his priority was national security.

"I have to see safety at home and — not a vast difference, by the way — but a little bit more. But it’s not a lot more, it’s a little bit more. I have to see safety at home. And if I think people are likely to do some very bad things in faraway places to our homeland, I’m going to have troops there for a period of time," Trump told the AP.

President Donald Trump at Joint Base Andrews in September 2017. Senior Airman Delano Scott/US Air Force photo

"But we’ve done an excellent job. We’ve defeated ISIS. ISIS is defeated in all of the areas that we fought ISIS, and that would have never happened under President Obama," Trump added. "In fact, it is going the other way. And I think we fought extremely effectively on everything I’ve wanted to do. Now there will be a certain point where that takes place."

Trump has made similar claims before.

During his address to the UN General Assembly at the end of September, he said that because of the US military and its partners, the "bloodthirsty killers known as ISIS have been driven out from the territory they once held in Iraq and Syria."

The day before that speech, during an appearance with Egyptian leader Abdel Fattah al-Sisi, Trump said, "if you look at various parts of the Middle East, you look at Syria, we’ve wiped out ISIS. We're in the very final throes."

US military officials have promoted the progress they and partner forces have made against the terrorist group in Iraq and Syria. But they've noted that while the group is a husk of its former self, it remains a potent enemy in the territory it once controlled and still has the ability to inspire attacks abroad.

A man cries as he carries his daughter away from an ISIS-controlled part of Mosul toward Iraqi special forces soldiers during a battle in Mosul, March 4, 2017. Thomson Reuters

"Overall, ISIS is territorially defeated, but until we achieve an enduring defeat, we will continue to fight," Army Col. Sean J. Ryan, a spokesman for Operation Inherent Resolve, the US-led anti-ISIS task force, told reporters at the Pentagon on Tuesday.

Iraq soldiers and security forces ejected ISIS from Mosul, the country's second-largest city, in August 2017, after eight months of grinding fighting. But ISIS fighters, many of whom hid out in Iraq's mountainous areas, remain in the country, operating like guerrillas.

Encounters with ISIS militants have become daily occurrences in the northeast provinces of Kirkuk, Salahuddin, Diyala, and Sulaimaniyah, according to a report by The Intercept. The fighters operate with relative ease in rural areas and at night, pressuring civilians for food and water and calling their cellphones to demand information about Iraqi security forces.

Iraq's military and federal police are "working to contain and eliminate ISIS, who still pose a threat," Ryan said on Tuesday, adding that security forces are still mopping up "small pockets of ISIS" that threaten stability.

In Syria, ISIS has also been beaten back. The US-backed Syrian Democratic Forces recaptured Raqqa, ISIS' self-proclaimed capital, in October 2017. But pockets of resistance persist, and US-backed fighters are still battling ISIS holdouts who often fight to the death.

SDF fighters ride on military vehicles as they celebrate victory in Raqqa, Syria, October 17, 2017. REUTERS/Erik De Castro

"The Syrian Democratic Forces continue to clear the last stronghold of ISIS resistance in the Middle Euphrates River Valley," Ryan said on Tuesday, referring to a region in eastern Syria near the Iraqi border. "The SDF is making gains despite booby-trapped buildings, IEDs, and repeated attacks."

Ryan described ISIS as a "resilient enemy," and, as in Mosul, fighters in the valley are making increasing use of tunnels. Many there are foreign fighters who can't blend in among locals in Iraq or Syria. "They have nowhere to go," Ryan said. "They are either here to fight to the death or get killed."

While SDF's advances are eroding ISIS' capabilities, Ryan said, the terrorist group "remains a deadly adversary."

"The remaining fighters in the MERV are hardened and have shown every indication of being willing to fight until the end," he said.

Operation Roundup, a campaign to free the river valley of ISIS, began in May, when the US estimated ISIS had just 2% of the territory it once controlled. The SDF has cleared a few towns, but that estimate hasn't changed.

Ryan and other US officials have stressed there is no timetable for clearing the valley. "It's not about the land mass; it's about taking away ISIS capabilities," like weapons and support, Ryan said. "We're degrading them every day."

ISIS fighters are still present in Iraq. Chris McGrath/Getty Images

Even with ISIS gone, the sentiment the group exploited and the means it used to spread its influence are likely to remain open to another extremist group.

Chairman of the Joint Chiefs Gen. Joseph Dunford said Tuesday that the US and its partners have worked on the internet as they've worked on the ground to counter ISIS.

"Much as we have worked over the last few years to deny them sanctuary in the physical space we’ve done the same thing to deny them freedom of movement in cyberspace," Dunford told reporters during a meeting of national defense chiefs at Andrews Air Force Base.

"Among the many things we need to think about as we look at violent extremism into the future, their ability to leverage technology, cyber capabilities, information operations … is one of the things we need to anticipate and be out in front of," Dunford said.

Moreover, Dunford said, conditions that could make the public amenable to another ISIS-like group endure.

"Little progress has been made in addressing the underlying conditions that lead to violent extremism," Dunford said.

"Challenges remain in our political, our military, our intelligence, and our law-enforcement cooperation," he added. "Perhaps the greatest challenge facing us today is the danger of complacency."