WASHINGTON — The risk that all U.S. troops may be forced out of Afghanistan by the end of the year has set off concerns inside the U.S. intelligence agencies that they could lose their air bases used for drone strikes against al-Qaida in Pakistan and for responding to a nuclear crisis in the region.

Until now, the debate here and in Kabul about the size and duration of a U.S.-led allied force in Afghanistan after 2014 had focused on that country’s long-term security. But these new concerns also reflect how troop levels in Afghanistan directly affect long-term U.S. security interests in neighboring Pakistan, according to administration, military and intelligence officials.

The concern has become serious enough that the Obama administration has organized a team of intelligence, military and policy specialists to devise alternatives to mitigate the damage if a final security deal cannot be struck with the Afghan president, Hamid Karzai.

If President Obama withdrew all U.S. troops from Afghanistan, the CIA’s drone bases in the country would have to be closed, according to administration officials, because they could no longer be protected.

Save 75% on a Digital Subscription Today

Their concern is that the nearest alternative bases are too far away for drones to reach the mountainous territory in Pakistan where the remnants of al-Qaida’s central command are hiding. Those bases would also be too distant to monitor and respond as quickly if there were a crisis involving missing nuclear material or weapons from the arsenals in Pakistan and India.

The United States has said that if it is unable to reach a final security arrangement with Karzai, it is prepared, reluctantly, to pull out completely, as it did in Iraq in 2011.