An Afghan police officer frisks a man following the recapture of Kunduz by Afghan security forces. (Jawed Kargar/European Pressphoto Agency)

The Taliban announced Tuesday that it is withdrawing from the key northern Afghan city of Kunduz, the site of its first significant military gain since the militants were driven from power in late 2001.

The fall of Kunduz to the Taliban over two weeks ago raised serious questions about the ability of Afghan forces despite U.S.-led efforts over 14 years to bolster their position with training and equipment, at a cost of billions of dollars.

It also led to an American air attack on a hospital, during a counteroffensive, that left at least 22 people dead and prompted President Obama to issue an apology.

The Taliban, in a statement, said it was withdrawing to spare the civilian population of Kunduz further casualties. Afghan forces in recent days had been steadily pushing the Taliban fighters out of the city, and by Monday that task was nearly complete.

Government officials said life was returning to normal Tuesday in some parts of the city, the sixth-largest in Afghanistan, near the border with Tajikistan.

While consolidating gains inside the city, government forces were searching for those who had helped the militants in the capture of Kunduz.

“People have resumed their routine life, and we are trying to offer whatever service we can for those who were displaced,” said Qasim Jangalbagh, Kunduz’s police chief.

But police were also looking for Kunduz residents who, in a jubilant mood after the Taliban takeover, had taken and posted celebratory selfies, residents said.

Taliban fighters were active and present in several districts on the outskirts of the city, residents said. In neighboring Baghlan province, some feared that the retreating Taliban force, armed with heavy and small arms, might try to stage attacks.

Deep in its heartland in southern Afghanistan, the Taliban continued for the second day to block the key highway linking Kabul with the main southern city of Kandahar, residents and lawmakers said.

Farther south in Kandahar province, the U.S. military on Tuesday said U.S. and Afghan forces completed a major air and ground operation, “dismantling terrorist operations in the area” on Sunday.

After months of intelligence-gathering and planning, the operation began a week ago in Shorabak district. The United States conducted 63 airstrikes while Afghan forces engaged in several battles on the ground against al-Qaeda networks at two related sites, a U.S. statement said.

“This is one of the largest joint ground-assault operations we have ever conducted in Afghanistan,” said Brig. Gen. Wilson Shoffner, a U.S. military spokesman in Afghanistan. “We struck a major al-Qaeda sanctuary in the center of the Taliban’s historic heartland. This significant operation is a testament to the professionalism and expertise of our Afghan partners and demonstrates the growing capability of the Afghan security forces.”

The U.S. military said initial reports showed that “heavy weapons, IED-making material and other valuable intelligence data including foreign passports, laptops and associated IT media, digital cameras and cards, documents, and mobile phones were recovered.”

In addition, it said, “forces seized anti-aircraft weapons; rocket-propelled grenade systems with associated hardware and warheads; machine guns, pistols, rifles and ammunition.”

The Taliban could not be reached for comment on the Kandahar operation. But earlier, the militants said they had shot down a combat plane in southeastern Paktia province and had captured its pilot, who had ejected with a parachute.

The Taliban did not say whose plane it was or identify the pilot it claimed to have taken.

Read more:

The Pentagon’s evolving response to the Afghan hospital attack

Top U.S. general in Afghanistan: Hospital ‘mistakenly struck’

The bloody history of Kunduz, from Afghanistan’s ‘Convoy of Death’ to now