OPERATING BASE FENTY, Afghanistan (Reuters) - U.S. Defense Secretary Ash Carter warned of the threat from Islamic State in Afghanistan during a surprise visit days after the Pentagon painted a grim picture of worsening security there.

U.S. Defense Secretary Ash Carter pauses as he delivers remarks at The Association of the United States Army (AUSA) 2015 Annual Meeting and Exposition in Washington October 14, 2015. REUTERS/Carlos Barria

Carter met troops at a U.S. base near the city of Jalalabad in Nangarhar Province, where about 600 U.S. troops are stationed. Operating Base Fenty is a hub for training, logistics and counter-terrorism efforts across eastern Afghanistan.

Islamic State has seized swathes of territory in Iraq and Syria and in recent months mounted attacks on Afghan security forces in Nangarhar.

The group competes with the Taliban for territory and recruits, say U.S. officials.

“We are seeing little nests of ISIL (Islamic State) spring up around the world, including here in Afghanistan ... but I will say that that is a threat that we track very closely,” Carter told a news conference after meeting acting Afghan Defense Minister Masoom Stanekzai on Friday.

U.S. Army General John Campbell, who leads international forces in Afghanistan, said Islamic State had coalesced over the last five or six months in Nangarhar and Kunar provinces and had been fighting the Taliban for several months.

He estimated there were between 1,000 and 3,000 members of Islamic State in Afghanistan and said its presence had forced the Taliban to re-direct some resources away from fighting Afghan security forces.

“It doesn’t have the capability, I believe, to go to Europe and attack Europe and go to our homeland at this point,” Campbell said.

“Left unchecked it will. They’ve said they want to do that.”

In a report to the U.S. Congress released this week, the Pentagon said that from the beginning of the year to mid-November, there were 27 percent more high-profile attacks in the capital Kabul compared with the same period last year.

Afghan national defense and security forces also had 27 percent more casualties from the beginning of 2015 up to mid-November compared with the same period last year.

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

Recent setbacks include the brief capture of the northern city of Kunduz by the Taliban, a months-long struggle in Helmand province and an insurgent raid on the airport in the city of Kandahar last week that killed 50 civilians and security personnel.

Campbell said Afghan forces had shown resilience during a “very tough year” but would need assistance for some time.

“I do believe Afghanistan will continue to need our support and the international community’s support,” he said.

In mid-October, President Barack Obama reversed plans to reduce the U.S. military presence to a small protection force in Kabul, saying he would prolong the engagement by maintaining a force of 9,800 through most of 2016.

The U.S. troops have the missions of training and advising Afghan security forces and conducting counter-terrorism operations.