BANGI, Afghanistan - The scene was set for Northern Alliance troops to make another triumphant entrance into a city taken from the Taliban. Then everything went wrong.
Early yesterday afternoon, the word spread that a Taliban commander in Kunduz had switched his allegiance to the Northern Alliance and invited its troops to enter.
"Kunduz has been captured!" the Northern Alliance soldiers roared, and the tanks and troop carriers started their engines and rumbled toward the city.
But when the alliance's troops approached the fringes of Kunduz, they were met not with cheering crowds but with Taliban rockets. The soldiers, stunned, began to panic. So did the alliance commander, Gen. Daoud Khan, who stood on top of a hill, jerking his head about in confusion.
"I don't know what is happening," he said, his face drained of color. "We made contacts with commanders in the city. They told us they would embrace us."
With that, Khan, one of the senior military leaders of the alliance, scampered down the hill, jumped into his car and sped away. Hundreds of soldiers followed, falling down, falling under car wheels, yelling and shouting, trampling each other in a panic to get away.
"Let me on, let me on!" soldiers yelled, leaping onto car hoods and troop carriers as they ran from what appeared to be a Taliban ambush and counteroffensive. Some men were run over in the pandemonium. The drivers of troops carriers, desperate to get away, left their men behind.
The retreat stretched more than a mile and ended only when an alliance soldier threatened to shoot anyone who went farther.
The Taliban assault never came. But their defiant defense of Kunduz, even as their comrades across Afghanistan have been left reeling, suggests that the battle-hardened army, even if mortally wounded, has some life in it.
The confused series of events that led to Tuesday's panicked retreat revealed, if for only a moment, the fluid allegiances and conflicting loyalties that likely will form the backdrop of any Afghan government that succeeds the Taliban.
If, as alliance leaders say, they will refuse to work with former members of the Taliban, they might have to exclude many soldiers in their own ranks. The rapid collapse of the Taliban in the last week was made possible in large part by the defections of dozens of Taliban commanders and thousands of their troops.
At the outskirts of Kunduz, the familiar script went astray.
"In Afghanistan, this is the way wars are fought," Gen. Rosmuhammad Uria said with a shrug. "If the Taliban commanders agree to embrace us, all will be forgiven."
By late afternoon, the alliance had gathered itself again and its soldiers were marching back toward Kunduz. Fresh troops came as well, more than 2,000, most of them confident that the Taliban's final days are ticking away.
Yet in Kunduz, the Taliban's demise does not seem so sure. The Taliban garrison there, plus the remnants of the forces that had retreated from Mazar-e Sharif and Taloqan, are trapped. All their escape routes have been cut. Alliance leaders say Taliban forces there number 20,000, but that estimate is impossible to verify.
That leaves Taliban soldiers with two choices: Fight or defect.
As the day dawned, alliance commanders were playing the same game of chicken that has determined the outcomes of battles across the country. As they readied their men for battle, the commanders pleaded with Taliban commanders to switch sides. Hours before the attack on Kunduz was set to begin, Uria said he had obtained "secret" agreements with a number of Taliban commanders in Kunduz to allow the alliance to enter the city.
The erstwhile Taliban commanders balked at any suggestion that they had ever had divided loyalties.
"I was with the Taliban, yes, but all along I was spying on them," said Adbullah Gard, one of the Taliban commanders who defected and brought 1,000 troops to the alliance.
The ease with which the Taliban and Northern Alliance accept one into the other's ranks might help explain why there have been relatively few reports of atrocities against the Taliban as the movement collapses.