OPERATING BASE FENTY, Afghanistan - Defense Secretary Ash Carter warned Friday of the threat of deteriorating security in Afghanistan from a resurgent Taliban and a growing number of Islamic State fighters.

On a visit to about 600 U.S. troops on this remote base near Jalalabad in eastern Afghanistan, Carter said the Islamic State has created "little nests . . . around the world, including here in Afghanistan."

U.S. commanders estimate that the Sunni Muslim extremist group has 1,000 to 3,000 fighters here. Many apparently are former Taliban members who shifted allegiance.

The warning comes after a year that saw the Afghan army and police suffer more than 5,000 casualties as U.S.-led coalition troops steadily withdrew from the battlefield and Taliban attacks surged.

In September, Taliban fighters overran the northern town of Kunduz, the first urban area they had captured since the U.S.-led invasion in 2001.

Government forces later recaptured the city, but the battles revealed weaknesses despite tens of billions of dollars of U.S. aid and training over the last 14 years.

"The Taliban's advances in some parts of the country, even if only temporary, underscores that this is a tough fight and it's far from over," Carter said.

"It's also a dynamic fight, and as groups like [Islamic State] emerge on the battlefield, or al-Qaeda seeks to reestablish a safe haven, we must be prepared to deter their growth and counter the threats they pose," he added.

Carter arrived here after stops this week in Turkey, Bahrain and Iraq, where he visited Baghdad and the northern city of Irbil. He met with troops, allies, and commanders involved in the battle against Islamic State.

A Pentagon study released this week concluded that security in Afghanistan was worsening by almost any measure. It said the Taliban leaders "likely will try to build momentum from their countrywide attack strategy" next year.