Miller said he told Taliban officials “it’s important that the military sides set the conditions for a peaceful and political settlement in Afghanistan. … But we know that with that violence, it would be very difficult to achieve a political settlement.”

During a ceremony in Kabul on Monday, Miller transferred his command to another four-star general at a U.S.-based post as part of President Joe Biden’s plan to withdraw U.S. troops.

The withdrawal is set to conclude by Aug. 31, even as Taliban insurgents continue their attacks and gaining territory across Afghanistan.

For more reporting from the Associated Press, see below.

Miller has served as America’s top commander in Afghanistan since 2018. He handed over command of what has become known as America’s “forever war” in its waning days to Marine Gen. Frank McKenzie, the head of U.S. Central Command. McKenzie will operate from Central Command headquarters in Tampa, Florida.

In a flag-passing ceremony, Miller remembered the U.S. and NATO troops killed in the nearly 20-year war as well as the thousands of Afghans who lost their lives.

The Afghanistan National Defense and Security Forces, mostly funded by the United States and NATO, have put up resistance in some parts of the country, but overwhelmingly Afghan government troops appear to have abandoned the fight.

In recent weeks, the Taliban have gained several strategic districts, particularly along the borders with Iran, Uzbekistan and Tajikistan.

Afghanistan’s National Security Adviser Hamdullah Mohib, who attended the handover, said the U.S. and NATO withdrawal has left a vacuum that resulted in Afghanistan’s national security forces stranded on the battlefield without resupplies, sometimes running out of food and ammunition.

In comments after the ceremony, Mohib said the greatest impact of the withdrawal is a lack of aircraft to resupply troops. Currently, the government is regrouping to retake strategic areas and defend its cities against Taliban advances.

The Taliban control more than one-third of Afghanistan’s 421 districts and district centers. A Taliban claim that they control 85 percent of the districts is widely seen as exaggerated.

After Miller’s departure, a two-star admiral based at the U.S. Embassy in Kabul will oversee the U.S. military’s role in securing the American diplomatic presence in Kabul, including defending the Kabul airport.

Miller’s departure does not reduce the scope of the U.S. military mission in Afghanistan, since McKenzie will assume the authorities now held by Miller to conduct airstrikes in defense of Afghan government forces under certain circumstances. The conditions under which such strikes might be used are not clear, nor is it known for how long McKenzie will keep the strike authority.

A deal the U.S. struck with the Taliban in February 2020 included a promise from the insurgent movement not to attack U.S. and NATO troops, a commitment it appears they have largely kept.

While Washington is not saying how many troops remain in Afghanistan, a CENTCOM statement more than a week ago said the withdrawal was 90 percent complete.

Biden has reiterated that the U.S. will remain engaged in Afghanistan with humanitarian assistance. The U.S. also is committed to spending $4.4 billion annually to fund Afghanistan’s security forces until 2024.