General Austin 'Scott' Miller has handed over command – in the waning days of what has become known as America's 'forever war' – to Marine General Frank McKenzie, the head of US Central Command and another four-star general.
The move comes as Taliban insurgents continue to gain territory across the country.
Gen McKenzie will assume authority from his US-based post in Tampa, Florida, to conduct possible airstrikes in defence of Afghan government forces, at least until the US withdrawal concludes by August 31.
In a flag-passing ceremony, Gen Miller remembered the US and NATO troops killed in the nearly 20-year war as well as the thousands of Afghans who have lost their lives.
The outgoing commander said he had 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," he said.
The ceremony for Gen Miller handing over command marks the symbolic end to the US military mission in Afghanistan.
Gen Miller, who took command in 2018, has led US forces longer than any of his predecessors and was in charge when President Joe Biden announced that all US troops would leave by 11 September 2021, the 20th anniversary of the 9/11 terror attacks on New York and Washington.
Mr Biden last week announced the US military mission in Afghanistan will conclude on 31 August, adding "speed is safety" as the US seeks to end a war that has lasted nearly 20 years.
President Biden has, however, reiterated that the US will remain engaged in Afghanistan with humanitarian assistance.
The US is committed to spending $4.4bn annually to fund Afghanistan's security forces until 2024.