In this 2009 file photo, U.S. soldiers stand with Afghan in a joint patrol near Bagram Air Base in Afghanistan. Six U.S. soldiers were killed in a joint patrol Monday near the base. (Maya Alleruzzo/AP)

A deeply conflicted President Obama warned earlier this year when he extended the American troop presence in Afghanistan that he did not support “the idea of endless war.”

For Obama, the deaths Monday of six U.S. soldiers near Bagram air base underscore the perils of his decision to keep as many as 9,800 troops in Afghanistan through much of next year.

A war that Obama had pledged to end before he left office is now increasingly looking endless. That war followed him here to his native Hawaii, where he is on a two-week vacation with his wife and daughters.

Obama has spoken bluntly of the emotional toll that American military deaths have taken on him as he has dispatched troops to Iraq, Afghanistan and most recently Syria. Last month, he lashed out at critics urging him to do more militarily in Iraq and Syria, saying he wouldn’t send U.S. forces into combat just to look “tough.”

President Obama made remarks and answered questions at the G-20 summit in Turkey on Nov. 13, following the Paris attacks. He spoke out against critics playing "political games" with the U.S. troops in Afghanistan. (AP)

“Part of the reason is because every few months I go to Walter Reed, and I see a 25-year-old kid who’s paralyzed or has lost his limbs, and some of those are people I’ve ordered into battle,” Obama said. “And so I can’t afford to play some of the political games that others may.”

The remarks prompted a backlash from some Republicans, who accused Obama of politicizing American troops’ sacrifices.

The most recent deaths, coming just before Christmas and just a few months after Obama’s decision to extend the longest war in American history into his successor’s presidency, are likely to stick with the president.

He didn’t speak directly about the losses Monday; instead, his press secretary issued a statement.

“The United States condemns this cowardly attack on members of the U.S. and Afghan forces, and we remain committed to supporting the Afghan people and their government,” the statement said.

The deaths come at a particularly fraught moment in the long and often overshadowed Afghan war. In October, a U.S. warplane launched a barrage of strikes against a Doctors Without Borders hospital in the northern Afghan city of Kunduz, killing as many as 30 people and drawing widespread condemnation.

More recently, Taliban forces have made big gains throughout southern Afghanistan’s Helmand province, the site of some of the heaviest American casualties during the height of the U.S. troop presence. Afghan civilian casualties are at an all-time high for the 14-year war, according to the United Nations, and the Afghan government’s internal squabbling has prevented it from filling key positions, such as the Defense Ministry.

These were exactly the sort of problems that led Obama to abandon his initial pledge to end the American war in Afghanistan and bring home the vast majority of U.S. troops by the end of his presidency.

Under the current plan, Obama will keep about 9,800 troops in Afghanistan through much of 2016 and reduce the size of the American force to about 5,500 before he leaves office in 2017. There could, however, be heavy pressure from his successor to keep forces at the larger level.

Obama had hoped to leave office with only about 1,000 U.S. troops based at the U.S. Embassy complex in Kabul.

In October, he described the change in plans as a “modest but meaningful extension of our presence” that could make “a real difference” in Afghanistan, and emphasized that U.S. troops would not be taking part in direct combat or patrolling Afghan villages. Instead Obama said they would focus on “two narrow but critical missions”: advising Afghan forces and launching targeted counterterrorism strikes against groups that threatened the United States or its allies.

The Taliban’s growing strength and the Afghan army’s struggles have drawn U.S. troops deeper into a combat role than many expected. In Kunduz, American Special Operations teams on the ground called in the mistaken strike that destroyed the Doctors Without Borders hospital. In restive Helmand province, Special Operations soldiers have been working alongside Afghan troops on the front lines.

The troops killed Monday outside Bagram air base, the largest U.S. facility in the country, were taking part in one of the core missions that Obama outlined for U.S. forces in October: They were patrolling the area outside the sprawling base to push back insurgents and protect the facility and airfield from insurgent attacks.

For much of the war, American forces were rarely challenged around Bagram, which was well outside the Taliban’s traditional area of control. In recent months, however, that has changed, and the Taliban has launched rockets and mortar rounds at the base from nearby villages.

One of those rockets in June killed Krissie K. Davis, a 54-year-old civilian employee of the Defense Department from Talladega, Ala., who was working at the facility as an environmental expert, helping to remove excess U.S. equipment as the base shrunk.

In his announcement extending the U.S. presence, Obama acknowledged the inherent peril of the remaining work, even if he declined to call it combat. “Afghanistan remains dangerous; 25 brave Americans have given their lives there this year,” Obama said in October. “I do not send you into harm’s way lightly. It’s the most solemn decision I make.”

He praised Afghan troops for fighting “bravely and tenaciously,” even as he admitted they were “still not as strong as they need to be” to hold off the Taliban and ensure that groups such as al-
Qaeda never return to Afghanistan.

Twice in response to a shouted question from a reporter, Obama insisted that his decision not to end the war as planned was not a “disappointment.”

But the six deaths on Monday underscore Obama’s growing sense that he will leave office with one of his toughest and most important missions unfulfilled.