Obama addresses U.S. troops at Bagram Air Field, north of Kabul, in Afghanistan, in May 2014. (Saul Loeb/AFP/Getty Images)

President Obama is seriously weighing a proposal to keep as many as 5,000 U.S. troops in Afghanistan beyond 2016, according to senior U.S. officials, a move that would end his plans to bring U.S. troops home before he leaves office.

The proposal presented in August by Army Gen. Martin E. Dempsey, then-chairman of the Joint Chiefs of Staff, would focus the remaining American force primarily on counterterrorism operations against the Islamic State, al-Qaeda and other direct threats to the United States.

Obama has made no final decision on the plan, which was developed before the Taliban captured Kunduz in September; it was the first major city to fall to the Taliban since the war began in 2001.

Afghan security forces, supported by American planes and combat advisers, have since been able to retake most, if not all, of the city. But the initial collapse of the Afghan forces in Kunduz has fed long-standing worries that Afghan forces lack the necessary air support, logistics and intelligence capabilities to survive on their own after the U.S. military leaves the country.

The 3,000 to 5,000 troops envisioned under Dempsey’s proposal would be part of an emerging plan for a global counterterrorism footprint, developed after the Islamic State’s rampage through much of Iraq and Syria. Gen. John Campbell, the top U.S. commander in Afghanistan, also has developed as many as five options for a post-2016 presence that range from a small embassy force to as many as 7,000 troops.

Dempsey’s plan, however, has been the primary focus of White House debates in recent weeks. Dempsey, who retired as Joint Chiefs chairman in September, spent his final month in office responding to a request from Obama to flesh out his initial proposal.

The Dempsey plan envisions the United States maintaining a few bases, perhaps two or three, that could be used as “lily pads” to launch strikes against groups that threaten the United States, senior defense and administration officials said.

The lily-pad bases would potentially house American drones and fighter jets as well as elite counterterrorism troops, and could be at Bagram air base north of Kabul and one or two other airfields, said senior administration officials who spoke on the condition of anonymity to discuss internal planning.

The new plan would mark a major shift for the president, who appears to have abandoned his goal of ending the wars in Iraq and Afghanistan and is now searching for some “acceptable equilibrium, some minimal level of involvement, that avoids catastrophic reversals,” said James Dobbins, who served as Obama’s special representative for Afghanistan and Pakistan in 2013 and 2014.

Fourteen years after the Sept. 11, 2001, attacks, the Taliban remains the largest of an array of militant groups operating in Afghanistan and just over the border in Pakistan’s tribal areas. Cells of al-Qaeda fighters remain in the mountains of eastern Afghanistan, and a small presence of Islamic State fighters, loosely tied to the militant movement in Iraq and Syria, has formed.

The sudden emergence of the Islamic State after the U.S. withdrawal in Iraq has raised concerns about it metastasizing to Afghanistan. “There’s a feeling that we can’t afford to turn our back on this and allow it to grow,” Dobbins said. Maintaining a larger footprint would also make it easier for the United States to launch attacks in Pakistan, where the Obama administration has long conducted drone strikes on militant hideouts.

The additional troops are likely to be welcomed by Afghan President Ashraf Ghani, who has pressed the White House for more help in his war against the Taliban and others.

Speaking at the Pentagon, Gen. John Campbell, the commander of U.S. and NATO forces in Afghanistan, said Afghan troops under fire in Kunduz requested air support from U.S. forces. The airstrikes killed 22 in a Doctors Without Borders hospital. (Associated Press)

Several U.S. officials said the plan is to make a final decision on the post-2016 force soon — a move that would give the United States’ NATO partners in Afghanistan more time to prepare for their own post-2016 commitments. But other senior officials insisted that no such plans exist and that no announcement or final decision from Obama is imminent. A military official said the president’s is expected to decide by the end of the year.

The president could choose to dismiss Dempsey’s proposal and stick with his plan to reduce the U.S. footprint in Afghanistan to an embassy-based presence of about 1,000 American service members in Kabul, similar to the presence the United States maintained in Iraq after 2011. The White House has approved at least two changes to the departure plan Obama announced in May 2014.

After hearing the initial proposal, Obama told his commander that he was open to keeping more troops in Afghanistan but wanted Dempsey to bring him a more detailed blueprint, senior administration and defense officials said. Obama asked military commanders to work with intelligence officials to give him a better sense of the potential threat the Islamic State and al-Qaeda posed in the region over the coming years. The president also wanted a more detailed cost assessment of Dempsey’s proposal and the number of troops and civilians needed to support it.

One key concern for Obama was how many U.S. troops it would take to protect the relatively small lily-pad bases from a major Taliban attack. The Taliban’s seizure of Kunduz and its gains in southern Afghanistan have heightened those worries.

“What you don’t want to do is leave a force that’s just big enough to provide a juicy target for the bad guys, but that’s too small to defend itself,” said a senior U.S. official involved in the planning.

Obama has faced criticism from Republican lawmakers that his withdrawal plan didn’t recognize the shortcomings of the Afghan forces or the deteriorating conditions on the ground. Afghan troops have suffered casualties at an “unsustainable” rate over the last two fighting seasons, according to U.S. military officials.

The deliberations of the post-2016 presence take place as the Pentagon scrambles to explain an air attack over the weekend that killed 22 people at a Doctors Without Borders hospital in Kunduz.The northern city’s fall to Taliban fighters may strengthen the case for a larger American presence to advise Afghan troops.

“Kunduz has caused some people to think we may not need to be hasty,” a senior military official said. “The lesson of Iraq is very much on people’s minds.”

The official said the U.S. plan also hinged on the nation’s NATO allies making enduring commitments to train and advise the Afghan army, a move that would free up American forces to focus on counterterrorism. There are about 6,400 non-U.S. troops stationed in Afghanistan as part of the multi-national training mission.

The future NATO mission in Afghanistan will be a centerpiece of talks when Defense Secretary Ashton B. Carter meets with NATO defense ministers in Brussels on Thursday.

There is widespread skepticism among some senior administration officials that even the current U.S. force of 9,800 troops will be enough to break the battlefield stalemate in Afghanistan or force the Taliban to the negotiating table. Obama acknowledged such frustrations at a news conference Friday.

“It’s still hard,” he said of the Afghan training effort. “That’s not by virtue of lack of effort on our part, or a lack of commitment. We’ve still got 10,000 folks in Afghanistan. We’re still spending billions of dollars supporting that government, and it’s still tough.”

Juliet Eilperin contributed to this report.