A top U.S. general in Afghanistan steps down as the war ends and the Taliban sweep across much of the country.

KABUL, Afghanistan — The top American general in Afghanistan stepped down on Monday, a symbolic moment as the United States nears the end of its 20-year-old war and Taliban fighters sweep across the country.

At a muted ceremony at U.S. and NATO military headquarters in Kabul, Gen. Austin S. Miller ended his nearly three-year term as commander. His duties will be filled by two officials. Rear Adm. Peter G. Vasely, a former member of SEAL Team 6, will take charge of the security mission at the United States Embassy in Kabul. He will report to Gen. Kenneth F. McKenzie Jr., the head of the military’s Central Command, who will take over the broader military mission in Afghanistan.

“It’s important to me to say farewell,” General Miller said. The ceremony, which lasted less than an hour, was attended by high-ranking Afghan officials, including Abdullah Abdullah, who is leading peace negotiations. “Our job is now not to forget,” General Miller said.

General McKenzie, who arrived in Kabul on Monday, spoke afterward, assuring those present that the Americans were not abandoning the Afghan people in such dire times.

“It’s not the end of the story,” General McKenzie said. “It’s the end of a chapter.”

General Miller oversaw a military campaign aimed at keeping the Taliban at the negotiating table and the Afghan forces unified in the face of political uncertainty.

Despite thousands of airstrikes, increased civilian casualties and short-term tactical gains, it is unclear how successful the U.S. military effort was: The final agreement between the insurgent group and the United States in February 2020 clearly favored the Taliban, and the Afghan government was completely cut out of the deal.

The Taliban have seized control of more than 160 of the country’s roughly 400 districts in the last two months, and hundreds of Afghan troops have surrendered, giving up their U.S.-supplied equipment and fleeing, sometimes into neighboring countries. Key provincial cities in both the north and south are under siege, and Afghan government counterattacks have had limited success.