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.

U.S. 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 U.S. 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.

“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 U.S. 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.”

U.S. 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.

“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 U.S.-led anti-ISIS task force, told reporters at the Pentagon on Tuesday.

Related: Reports That ISIS Has Been Destroyed May Be Greatly Exaggerated »

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 U.S.-backed Syrian Democratic Forces recaptured Raqqa, ISIS' self-proclaimed capital, in October 2017. But pockets of resistance persist, and U.S.-backed fighters are still battling ISIS holdouts who often fight to the death.

“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.”

Trump Boasts That ‘ISIS Is Defeated.’ The Pentagon Says: Not Quite Yet

French fighters (or French speaking) of ISIS or Islamic State group or Daesh deliver a message to Francois Hollande and to French people, mourning the killers of Charlie Hebdo team, brothers Kouachi, as well as Amedy Coulibaly in a video message sent on internet on February 4th, 2015,.Associated Press photo

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 U.S. 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 U.S. 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.”

Related: The Army Has Been Quietly Pounding ISIS In Syria From A Brand New Fire Base In Iraq »

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 U.S. 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.”

Read more from Business Insider: