The fight for the police compound proved crucial in rallying Afghan forces to retake the city.

It also offered the starkest example to date of a blurry line in Afghanistan and Iraq between the missions that American forces are supposed to be fulfilling — military training and advising — and combat. Mr. Obama has portrayed that combat role as over. But as the Taliban in Afghanistan and the Islamic State in Iraq have threatened the delicate stability he hoped to leave behind, American forces are increasingly being called on to fight.

The fall of Kunduz “was clearly a desperate situation,” said Brig. Gen. Charles H. Cleveland, the spokesman for the American command in Afghanistan. The soldiers, he said, recognized that “if we don’t really provide some very strong suggestion, direction, whatever you call it — if we don’t get engaged with this quickly — we’re going to have a much larger issue.”

In interviews with military investigators, Green Berets who fought in Kunduz for the four days it ultimately took to begin securing the city provided a graphic and previously undisclosed account of one of the most important engagements of the war. The investigators’ main purpose was to examine not that battle, but the tragedy that stemmed from it. It was these Green Berets who, on the morning of Oct. 3, in the heat of battle, called in the airstrike that killed 42 people at a hospital in Kunduz run by Doctors Without Borders, prompting an international outcry and disciplinary action against 16 military personnel.

The investigators wanted to know how the strike occurred. But the interviews they conducted also revealed almost universal confusion among the Green Berets over their exact mission in Kunduz. The goal was simple: not to lose the city. But in a reflection of the ill-defined parameters of the United States’ mission in Afghanistan, no one involved in the battle seemed to know how far the group was supposed to go to ensure success.