President Obama’s decision to maintain troop levels in Afghanistan through 2015 is partly designed to bolster American counterterrorism efforts in that country, including the Central Intelligence Agency’s ability to conduct secret drone strikes and other paramilitary operations from United States military bases, administration officials said Tuesday.

Mr. Obama on Tuesday announced that he would leave 9,800 American troops in Afghanistan until at least the end of the year. The announcement came after a daylong White House meeting with President Ashraf Ghani of Afghanistan. The two men said the decision was a necessary response to the expected springtime resurgence of Taliban aggression and the need to give more training to the struggling Afghan security forces.

But two American officials said that a significant part of the deliberations on the pace of the withdrawal had been focused on the need for the CIA and military special operations forces to operate out of two large military bases: Kandahar Air Base in southern Afghanistan and a base in Jalalabad, the biggest city in the country’s east. Reducing the military force by half from its current level, as planned, would have meant closing the bases and relocating many of the CIA’s personnel and its contractors.

Jalalabad has been the primary base used by the CIA to conduct drone strikes in the tribal areas of Pakistan. The drone operations were relocated there after the Pakistani government kicked the CIA out of an air base inside Pakistan. The pace of drone strikes there has declined significantly since the peak during the early years of the Obama administration, but intelligence officials have lobbied to keep enough of a military presence in Afghanistan to allow the drone program to continue.

“The intelligence community sees around 10,000 troops as a key baseline to keep counterterrorism operations going in the country,” said one American official, speaking on condition of anonymity to discuss classified operations in Afghanistan.

The resilience of Al Qaeda in the mountains that straddle the border between Afghanistan and Pakistan has surprised many American officials, and there are fears that the Islamic State could gain a foothold in the Afghan conflict. Mr. Ghani has repeatedly raised the specter of the Islamic State in comments ahead of his trip to Washington and during his visit.

In a news conference on Tuesday, Mr. Obama pledged to “continue to conduct targeted counterterrorism operations” in Afghanistan. But he stressed the need for “flexibility” on troop levels as a way to maintain the overall security posture of Afghan forces in the country.

“This flexibility reflects our reinvigorated partnership with Afghanistan, which is aimed at making Afghanistan secure,” Mr. Obama said, adding later that “we want to make sure that we’re doing everything we can to help Afghan security forces succeed.”

When Mr. Obama’s advisers were first debating what presence the military should have in Afghanistan beginning in 2015, after the end of formal “combat operations,” American officials determined that a minimum of about 10,000 troops would be needed for two broad missions: training and advising Afghan soldiers as well as carrying out counterterrorism operations - a generic term for military special operations missions and CIA drone strikes in Pakistan.

If that number of troops were to decline significantly, intelligence officials have warned that they may have to reconsider how large a CIA presence to keep inside Afghanistan.

The administration’s original plan envisioned that by 2015, Afghan special forces would largely take on the role that American-led special operations troops have played in the war: targeting Qaeda operatives and carrying out raids aimed at eliminating Taliban field commanders, one of the few tactics that have proved effective in undermining the insurgency.

But the elite Afghan soldiers remain heavily reliant on their American counterparts, although they are considered far better than Afghanistan’s conventional troops. They have only limited airlift capabilities - a serious deficiency in a country as mountainous as Afghanistan - and they do not have the high-end intelligence-collecting technology of the American forces.

The Afghans also do not have armed drones, which have been used with increasing frequency in recent years in Afghanistan against Qaeda and Taliban targets. The drones flown in Afghanistan are operated by the American military; the ones used across the border in Pakistan are operated by the CIA

The base in Jalalabad is also a hub for the collection of intelligence on Qaeda operations in Afghanistan and Pakistan; it was, for instance, the base from which American forces carried out the 2011 raid that killed Osama bin Laden in Pakistan.

Mr. Obama’s decision on the troop levels came after a direct entreaty from Mr. Ghani, who has been visiting the United States this week. While the decision will mean that some American soldiers who had expected to return home will rotate back into Afghanistan “for a few extra months,” Mr. Obama said, the additional time will be “well worth it.”

The extension was needed in part “so we don’t have to go back,” Mr. Obama said, “so we don’t have to respond in an emergency because terrorist activities are being launched out of Afghanistan.”

Mr. Ghani, who expressed gratitude to American troops and taxpayers for their support, said the extension would allow his military to better prepare for the total withdrawal of United States forces, still scheduled for the end of 2016.

“Much binds us together, and the flexibility that has been provided for 2015 will be used to accelerate reforms to ensure that the Afghan security forces are much better led, equipped, trained, and are focused on their fundamental mission,” Mr. Ghani said, speaking in mostly English during the news conference.

The announcement was not unexpected. Administration officials had strongly suggested in recent days that Mr. Obama would agree to slow the pace of the troop withdrawal.

Mr. Ghani, making his first trip to the United States as president of his country, met throughout the morning with Mr. Obama and Vice President Joseph R. Biden Jr., discussing the future of American involvement in what Mr. Obama once declared a “necessary” war.

Mr. Obama has pledged to withdraw all but about 1,000 troops by the time he leaves office at the beginning of 2017. Those forces would operate largely in the Afghanistan capital, Kabul, protecting embassy personnel and other American officials there.

While acknowledging the need to maintain force levels through at least the end of 2015, Mr. Obama reiterated his intent to keep that promise as he hands over the keys to the Oval Office to his successor.

“The date for us to have completed our drawdown will not change,” he said Tuesday. Mr. Ghani’s meetings with his American counterpart were part of a five-day visit to the United States that included a series of discussions on Monday at Camp David, the presidential retreat in the mountains of Maryland.

His trip will continue Wednesday with an address to a joint meeting of Congress, and on Thursday, when Mr. Ghani will meet with world leaders at the United Nations.

While the primary mission of Mr. Ghani’s trip is a military extension, he is also using his visit as a public-relations blitz aimed at repairing Afghanistan’s reputation as a country whose leaders have taken American help for granted over the past decade.

In a series of appearances Monday and Tuesday, Mr. Ghani repeatedly thanked American troops for their sacrifices in his country, and he promised that Afghanistan would reciprocate by building a government that could stand on its own economically, socially and militarily.

“You stood shoulder to shoulder with us, and I’d like to say thank you,” Mr. Ghani said at the news conference on Tuesday. “I would also like to thank the American taxpayer for his and her hard-earned dollars that has enabled us.”–NY Times