At least 9,800 U.S. troops will remain in Afghanistan through the end of 2016 to provide support to that nation’s defense and security forces as they continue to build the capability to fight terrorism and protect their own government against a resurgent Taliban and the rise of Islamic State sympathizers, Defense Secretary Ashton Carter said Oct. 15.

President Barack Obama announced earlier the same day that the administration’s declared policy of drawing down to fewer than 1,000 troops by the time he leaves office had shifted in light of recent events. The plan now is to retain 9,800 U.S. troops through most of 2016, then draw down to about 5,500 for the foreseeable future.

“What I’ve heard over the last eight months is that Afghanistan is on a better path, but more work lies ahead and America’s national security lies very much at stake in that part of the world,” Carter said. “After considering input from me, our top military leaders, the rest of his national security team, our NATO allies and the government of Afghanistan, the resident announced his decision to maintain our current force posture of 9,800 troops through most of next year.”

By January of 2017, the plan is to draw down to about 5,500 troops that will be deployed at a few strategic bases in the country, to include the capital Kabul, Bagram, where there is a major U.S. air base, Kandahar, and Jalalabad.

Carter could not provide a breakdown of the troop mix that would remain in theater, but said the two primary missions would include counterterrorism–which suggests special forces personnel–and advising and assisting the Afghan National Defense and Security Forces (ANDSF).

To Afghan President Ashraf Ghani, Carter said “we are with you and we are not going to give up the gains we fought so hard to achieve.” To date 2,200 U.S. personnel have died in the war in Afghanistan, the nation’s longest sustained conflict.

The policy adjustment is bases on conditions as they exist today and represent an alteration of a drawdown plan that was put in place more than two years ago, Carter said. Recent Taliban offenses are part of the equation but not the ultimate determinant that led officials to advise the residual troop presence. Carter also said the United States was maintaining its presence at the behest of the Afghan government.

NATO allies also have promised support in manpower and materiel to continue the mission to establish and prop up a viable Afghan army and its law-enforcement agencies, Carter said.

“We are adjusting our presence based on conditions on the ground, to give the Unites States and our allies the capability to sustain a robust counterterrorism platform, denying a safe haven for terrorist or violent extremist organizations. This will keep Americans safer back home.”

Despite recent setbacks including the taking of Kunduz–which has since been regained by ANDSF forces with the help of U.S. airstrikes–and the reported defection of former Taliban members to the ranks of Islamic State-aligned groups in the country, Carter said the ANDSF remains an effective fighting force. He praised their performance in the just-passed fighting season, which was the first that they took point without combat support from U.S. troops on the ground.

“But Taliban advances in parts of the country underscore the reality that this is, and remains, a difficult fight,” Carter said. “We understand that Afghanistan still needs assistance.”