FILE - U.S. troops stand guard during a handover ceremony of A-29 Super Tucano planes from U.S. to the Afghan forces, in Kabul, Sept. 17, 2020.
FILE - U.S. troops stand guard during a handover ceremony of A-29 Super Tucano planes from U.S. to the Afghan forces, in Kabul, Sept. 17, 2020.

WASHINGTON - Roughly 650 U.S. troops are expected to remain in Afghanistan to provide security for diplomats after the main American military force completes its withdrawal, which is set to be largely done in the next two weeks, U.S. officials told The Associated Press on Thursday.

In addition, several hundred additional U.S. forces will remain at the Kabul airport, potentially until September, to assist Turkish troops providing security, as a temporary move until a more formal Turkey-led security operation is in place, the officials said.

Overall, officials said the U.S. expects to have American and coalition military command, its leadership and most troops out by July 4th, or shortly after that, meeting an aspirational deadline that commanders developed months ago.

The officials were not authorized to discuss details of the withdrawal and spoke to the AP on condition of anonymity.

President Joe Biden speaks from the Treaty Room in the White House on Wednesday, April 14, 2021, about the withdrawal of the remainder of U.S. troops from Afghanistan.

The departure of the bulk of the more than 4,000 troops that have been in the country in recent months is unfolding well before President Joe Biden's Sept. 11 deadline for withdrawal. And it comes amid accelerating Taliban battlefield gains, fueling fears that the Afghan government and its military could collapse in a matter of months.

Officials have repeatedly stressed that security at the Hamid Karzai International Airport in Kabul is a critical requirement to keeping any U.S. diplomatic staff in Afghanistan.

Still, the decision to keep additional troops there for several more months makes it more complicated for the Biden administration to declare a true end to America's longest war until later this fall. And it keeps the embattled country near the forefront of U.S. national security challenges, even as the White House tries to put the 20-year-old war behind it and focus more on threats from China and Russia.

On Friday, Afghan President Ashraf Ghani and Abdullah Abdullah, chair of the High Council for National Reconciliation, are meeting with Biden at the White House. The two Afghan leaders also are scheduled to meet at the Pentagon with Defense Secretary Lloyd Austin and possibly other administration officials, the Pentagon announced.

Getting most troops out by early July had been in doubt because of complications including an outbreak of COVID-19 at the U.S. Embassy and the push to get Afghan interpreters and others who helped the U.S. out of the country. Officials said U.S. commanders and NATO allies in Afghanistan have been able to overcome logistical hurdles that might have prolonged the withdrawal process. But they also warned that plans in place for the final stages of the U.S. military withdrawal could change if airport security agreements fall through or there are other major, unforeseen developments.

FILE - A NATO helicopter flies over the city of Kabul, Afghanistan.

As recently as last week, there was discussion of possibly extending the U.S. troop presence at Bagram Airfield, north of Kabul, but officials said the U.S. presence at the base is expected to end in the next several days.

The roughly 650 U.S. troops that are planned to be a more permanent force presence in Afghanistan will provide security for the U.S. Embassy and some ongoing support at the airport. Officials said the U.S. has agreed to leave a C-RAM — or Counter-Rocket, Artillery, Mortar system — at the airport, as well as troops to operate it, as part of an agreement with Turkey. The U.S. also plans to leave aircrew for helicopter support at the airport.

According to the officials, Turkey has largely agreed to provide security at the airport as long as it receives support from American forces. U.S. and Turkish military officials are meeting in Ankara this week to finalize arrangements.