WASHINGTON — President Obama’s advisers wrestled with an intractable problem in the spring and summer of 2015: How could they stabilize Afghanistan while preserving Mr. Obama’s longtime goal of pulling out the last American troops before he left office?
As it happened, the president solved the problem for them. In early August of that year, when Mr. Obama convened a meeting of the National Security Council, he looked around the table and acknowledged a stark new reality.
“The fever in this room has finally broken,” the president told the group, according to a person in the meeting. “We’re no longer in nation-building mode.”
What Mr. Obama meant was that no one in the Situation Room that day, himself included, thought that the United States — after 14 years of war, billions of dollars spent and more than 2,000 American lives lost — would ever transform Afghanistan into a semblance of a democracy able to defend itself.
At the same time, he added, “the counterterrorism challenges are real.” As bleak as Afghanistan’s prospects were, the United States could not afford to walk away and allow the country to become a seedbed for extremists again.
A few weeks later, the president halted the withdrawal and announced that he would leave thousands of American troops in the country indefinitely.
It was a crucial turning point in the evolution of Barack Obama. The antiwar candidate of 2008 who had pledged to turn around Afghanistan — the “good war” to George W. Bush’s “bad war” in Iraq — had conceded that the longest military operation in American history would not end on his watch. The optimistic president who once thought Afghanistan was winnable had, through bitter experience, become the commander in chief of a forever war.
He remains defensive about the lessons of that journey. “We shouldn’t assume that every time a country has problems that it reflects a failure of American policy,” the president said in an interview in September.
Now, as Mr. Obama prepares to turn the war over to Donald J. Trump, a leader even more skeptical than he is about the value of American engagement in foreign conflicts, Afghanistan captures the disillusionment of a man who believed, as he put it in his 2009 Nobel Peace Prize acceptance speech, “that war is sometimes necessary, and war at some level is an expression of human folly.”
More than any other conflict, Afghanistan shaped Mr. Obama’s thinking on the basic questions of war, peace and the use of military power. It is where he discovered his affinity for drones, sharpened his belief in the limits of American intervention, battled his generals and hardened his disdain for unreliable foreign leaders. It reaffirmed his suspicions about sending American troops into foreign conflicts and made him reluctant to use more force in Iraq, Syria, Libya and other war zones.
It also chastened him about his own hopes.
“When it comes to helping these societies stabilize and create a more secure environment and a better life for their people, we have to understand,” he said in the interview, “that this is a long slog.”
‘A War That We Have to Win’
Mr. Obama was a state senator from Illinois in October 2002 when he famously condemned Iraq as a “dumb war.” But in the same speech he also said, “I don’t oppose all wars.” He was referring to Afghanistan, which he viewed as a just war to hunt down the perpetrators of the Sept. 11 terrorist attacks.
“I would willingly take up arms myself to prevent such tragedy from happening again,” he told the crowd that day in Chicago’s Federal Plaza.
By July 2008, as the Democratic nominee for president, Mr. Obama had embraced Afghanistan as a priority over Iraq — the “good war,” in a phrase that he never actually used himself but that became so associated with his approach it was sometimes wrongly attributed to him.
Mr. Obama praised the Bush administration’s troop surge in Iraq that year not because he believed that the United States could transform Iraqi society, but because he thought that reducing the violence there would allow the nation to turn its attention to Afghanistan.
“This is a war that we have to win,” he declared. He promised to send at least two more combat brigades, or roughly 10,000 soldiers, to Afghanistan.
The United States was hardly on course for victory. Although there were already close to 50,000 American troops in Afghanistan as Mr. Obama campaigned that summer, the Taliban were gaining momentum. In a bloody debacle, nine American soldiers were killed in what became known as the Battle of Wanat when the Taliban brazenly overran a remote Army outpost in the far eastern province of Nuristan.
Adm. Mike Mullen, the chairman of the Joint Chiefs of Staff, echoed Mr. Obama in calling the situation in the country “precarious and urgent.” More than 100 Americans would die in Afghanistan by the end of 2008, a larger number than in any other prior year.
When Mr. Obama took office in January 2009, he ordered a quick policy review on Afghanistan by a former intelligence analyst, Bruce Riedel. But even before it was completed, he accepted a Pentagon recommendation to send 17,000 additional troops to Afghanistan, bringing the total to nearly 70,000 American troops on the ground.
By the fall of 2009, with the Taliban showing increased strength, Mr. Obama’s military commanders, backed by the elders on his war council, including Hillary Clinton, then his secretary of state, were pressing him to go much farther.
They urged on him an ambitious counterinsurgency strategy that had helped turn around the war in Iraq — a troop-heavy, time-consuming, expensive doctrine of trying to win over the locals by building roads, bridges, schools and a well-functioning government.
The strategy, known by its acronym COIN, would require as many as 40,000 additional American men and women in uniform in Afghanistan, his advisers told him.
“There was still the afterglow of the surge in Iraq, and the counterinsurgency narrative that had made the military the savior of the Iraq war,” said Vali R. Nasr, a former State Department adviser on Afghanistan and Pakistan. “I don’t believe Obama was in a position to pick a debate with the military on Afghanistan, and to assert what would be his worldview.”
“In many ways, I think, he deferred,” said Mr. Nasr, now the dean of the Johns Hopkins School of Advanced International Studies.
Although Mr. Obama agreed after months of internal debate to send 30,000 additional troops to Afghanistan, he placed a strict timetable on the mission, saying they would have to be withdrawn again, starting in July 2011. His aides later said he felt hijacked by a military that had presented him with a narrow band of options rather than a real choice.
Even some former military commanders agreed, saying that the troop deployments were framed in a way that made choosing a smaller number — 20,000, for example — look like a path to certain defeat.
“President Obama was asking the military for broad options,” said Karl W. Eikenberry, a retired general who served as the commander in Afghanistan from 2005 to 2007 and was later Mr. Obama’s ambassador to Kabul. But, he said, the military gave Mr. Obama only “variations” on “the more robust counterinsurgency model.”
Mr. Eikenberry, who wrote a politically explosive but prescient cable in late 2009 raising doubts about the wisdom of the surge, diagnosed a deeper problem with the policy. Was it simply to prevent Afghanistan from being a safe haven for Al Qaeda? Or was it to turn Afghanistan into another Denmark? “When he came in, everyone knew we were going to do more,” Mr. Eikenberry said. “But what we were trying to achieve was difficult to define.”
Given Mr. Obama’s innate wariness of nation-building, it didn’t take long for him to grow disenchanted with the Denmark option. A few months into the surge, in the spring of 2010, David H. Petraeus, the commander of the Pentagon’s Central Command and an architect of the strategy, was briefing him on the state of the counterinsurgency campaign.
Drawing on anthropology theory from the University of Chicago, General Petraeus explained to his commander in chief how neighborhoods in Kandahar related to one another. Mr. Obama listened for a while, then cut him off. “We can’t worry about how neighborhoods relate to each other in Kandahar,” he curtly told General Petraeus, according to people in the room.
“Obama believes the military can do enormous things,” said Benjamin J. Rhodes, the deputy national security adviser. “It can win wars and stabilize conflicts. But a military can’t create a political culture or build a society.”
‘Afghan Good Enough’
By the end of his first term, Mr. Obama had evolved to the point that he fully embraced the concept “Afghan good enough.” The phrase, which had been kicked around the White House since 2010, referred to the shift away from nation-building to a policy that was content with taking out the terrorists, preventing the Taliban from overrunning the country and putting a premium on getting the troops out.
By that new standard, things had improved in Afghanistan. By August 2010, 100,000 American troops were on the ground in Afghanistan and were pushing back the Taliban in some critical areas. Despite uneven progress in the military campaign, Ryan Crocker, a diplomat who had reopened the American Embassy in Kabul in 2002 and served there again as ambassador in 2011, recalled thinking, “Wow, this place looks great!”
The Navy SEAL raid that killed Osama bin Laden in Pakistan in May 2011 added to Mr. Obama’s conviction that he was on the way to closing the books on the war.
At midnight on May 1, 2012, Air Force One rolled out from behind a hangar at Joint Base Andrews to pick up the president for a secret trip to Afghanistan. He was going to sign a strategic partnership agreement with President Hamid Karzai that set the terms for relations after 2014, when the United States was scheduled to withdraw its combat troops and turn over Afghanistan’s security to the Afghans.
Aides to Mr. Obama had advised him not to go for security reasons, but he saw it as an important milestone.
The agreement promised an “enduring partnership” between the United States and Afghanistan, with pledges of American help in developing the Afghan economy and public institutions. Yet the promises obscured a starker reality: Mr. Obama had accelerated the timetable for drawing down American troops, and he was looking beyond the war.
Speaking to a national TV audience from Bagram Air Base, he suggested that America’s experience in Afghanistan had come full circle. “One year ago, from a base here in Afghanistan, our troops launched the operation that killed Osama bin Laden,” he said. “The goal I set — to defeat Al Qaeda, and deny it a chance to rebuild — is now within our reach.”
Earlier, Mr. Obama had met for an hour with Mr. Karzai. The two had long had a rocky relationship — on an earlier trip, Mr. Obama excoriated Mr. Karzai for the rampant corruption in the Afghan government — and this session did little to improve their rapport. Mr. Crocker recalled that the president was “very aloof, almost cold, which bothered me a bit because I’d worked a solid damn year to get Karzai in a better place with us.”
Things never warmed up between them. When Mr. Karzai refused to sign a long-term security agreement with Washington, Mr. Obama gave up on him to focus on his successor, Ashraf Ghani. The experience left a lasting imprint on the president, his aides said. He concluded that without the right partner, it was impossible for the United States to succeed, no matter how much blood and treasure it poured into a country.
It was an insight that Mr. Obama applied to his relations with other countries, from Pakistan to Israel, where his poor relationships with the leaders impeded progress. “The most underappreciated part of foreign policy,” Mr. Rhodes said, “is dealing with flawed partners.”
ISIS, a New, Radiating Threat
When Mr. Obama convened his National Security Council that day in August 2015, the Taliban were regrouping again. They had carried out audacious terrorist attacks in the center of Kabul and had mounted a military offensive in the provinces of Kunduz and Oruzgan.
Worse, there was a new threat in the form of the Islamic State, also known as ISIS or ISIL, which sprouted in the poisonous soil of Iraq after the United States left and was finding recruits in the Hindu Kush.
Mr. Obama had rejected a chorus of calls in Washington to delay the drawdown, under which the residual force of American troops was to leave Afghanistan by the end of 2016.
“The mantra I heard was that the president does not want to hand off to his successor the mess he inherited,” said Daniel F. Feldman, who served as the special representative to Afghanistan and Pakistan in 2014 and 2015.
But as the Islamic State became a dire enough threat to return American troops to Iraq, Mr. Obama felt compelled to change course on Afghanistan. “ISIL thrived in a vacuum in Iraq and it pointed to a similar vacuum in Afghanistan,” Mr. Rhodes said.
Mr. Obama, he said, was prodded by more than fear. After a long stretch of political paralysis, Afghanistan formed a government with Mr. Ghani in the presidency. For the first time since taking office, Mr. Obama felt like he had a partner with whom he could do business. The American-trained Afghan Army was taking heavy casualties fighting the Taliban, and the president believed that the United States had an obligation to help them.
But as Mr. Obama’s war council met that August morning, the level of American support remained the subject of intense debate.
Vice President Joseph R. Biden Jr., a skeptic about Afghanistan going back to 2009, argued that the country would revert to chaos, regardless of how long the United States stayed there. “It doesn’t matter if we leave tomorrow or 10 years from now,” he declared, according to those in the room. He was, he conceded, a “broken record” on this issue.
Gen. Martin E. Dempsey, who had succeeded Admiral Mullen as chairman of the Joint Chiefs of Staff, recommended that the United States maintain a military presence in Kabul, and at Bagram and a scattering of bases in the east and south. The 10,000 soldiers in the country would carry out a singular, ruthless mission of killing suspected terrorists and keeping the country from spiraling out of control.
The imperative, General Dempsey told Mr. Obama, was that Afghanistan fit into a broader counterterrorism policy from Central Asia to North Africa to extend “well beyond your presidency,” according to several officials.
Mr. Obama liked that idea. It was in line, he said, with the principles he had laid out in a 2014 speech at the United States Military Academy in West Point, N.Y., where he said America would train and equip foreign armies but leave the front-line fighting to them. He acknowledged that it would mean handing off Afghanistan to his successor as unfinished business.
“This goes to the politics of what I’m leaving for the next president,” he told the group, according to one of the participants. “My interest is not to sign them up for 10 years of X,” he added, referring to troop numbers, “but to lay out a vision and to put stakes in the ground for that vision.”
Mr. Obama now seems at an uneasy peace. In the interview in September, he disputed the suggestion that his policy had failed. He had, after all, reduced the number of American troops to fewer than 10,000 from more than 100,000. They were training and assisting Afghan troops, even if the line between that and actual combat was sometimes blurry.
The country had been broken to begin with, he said, and America was never going to fix it. “Afghanistan was one of the poorest countries in the world with the lowest literacy rates in the world before we got there. It continues to be,” Mr. Obama said. The country “was riven with all kinds of ethnic and tribal divisions before we got there. It’s still there.”
In the end, Afghanistan became the template for a new kind of warfare — a chronic conflict, across an arc of unstable states, in which the United States is a participant, if not the principal actor.
At a NATO summit meeting in Warsaw in July, Mr. Obama acknowledged that this prospect would disappoint an American public still suffering from combat fatigue. “It’s very hard for us ever to get the satisfaction of MacArthur and the emperor meeting, and a war being officially over,” he said.
“As commander in chief of the most powerful military in the world,” he went on, “I spend a lot of time brooding over these issues. And I’m not satisfied we’ve got it perfect yet.”