KABUL — Senior Afghan officials and hundreds of Afghan government forces in the country’s west and south surrendered to the Taliban on Friday after the militants overran three key cities, inching the country closer to collapse in the final days of the U.S. withdrawal.

The recent advances by the militant group, largely achieved with little resistance from Afghan government forces despite years of U.S. training and support, are isolating the Afghan capital with stunning speed, increasingly weakening the administration of President Ashraf Ghani, and further hastening efforts by the United States and its allies to enhance security while foreign governments work to extract embassy staff and local Afghans who have assisted the U.S.-led coalition.

In the western city of Herat, an entire Afghan army corps crumbled, with hundreds of troops handing over their weapons to the Taliban and others fleeing, according to local officials. The surrender deal was brokered, they said, by a group of Taliban leaders who met with Afghan government and security forces at the military base where they were holed up after the city was overrun Thursday.

The province’s governor, intelligence chief, chief of police and a prominent anti-Taliban militia leader also resigned their posts in exchange for Taliban protection, said Ghulam Habib Hashimi, a legislative official.

The Taliban’s advance across the nation’s south on Friday, staggering in speed and scale, leaves the insurgents holding half of Afghanistan’s 34 provincial capitals and controlling roughly two-thirds of the country.

In the southern province of Helmand, where U.S. and British Marines sustained heavy casualties in a fraught, years-long fight to repel the Taliban and shore up the local government, hundreds of Afghan forces surrendered and ceded control of the capital, Lashkar Gah, according to Mirwais Khadem, a parliament member.

And in Kandahar, Afghanistan’s second-largest city, government control has shrunk to the local airport and adjoining military base. Sayed Ahmad Seylab, a provincial council member, said Afghan forces and officials retreated from the main government compound to “avoid civilian casualties and the destruction of Kandahar city.”

» READ MORE: Deceptions and lies: What really happened in Afghanistan

The mass surrenders of Afghan security forces and government personnel are accelerating Taliban advances across Afghanistan, undercutting the military’s morale and supplying the militants with weaponry. On Friday, the capitals of Ghowr, Zabul, Logar and Uruzgan provinces fell, the highest number in a single day.

Kandahar’s governor, police chief and several other officials abandoned administrative buildings overnight, according to Seylab. In Herat, a similar scenario unfolded, according to Hashimi, a provincial council member, who said the city’s main officials fled to a military base before surrendering.

In Helmand province, after weeks of intense clashes during which Taliban fighters besieged the local government compound in Lashkar Gah, Afghan forces abandoned the cluster of buildings for a military base, according to Khadem.

Now all eyes are on Kabul, as the militants gradually close in on the capital. Its advances are heightening concern that Afghanistan’s government will largely collapse, leaving the city an island surrounded by Taliban-controlled territory. A new U.S. intelligence assessment has indicated Kabul could be overrun within 30 to 90 days.

American officials here raced on Friday to prepare for a Taliban takeover. Inside the U.S. Embassy, diplomats began destroying classified documents and equipment on orders from embassy leadership. An internal memo, obtained by The Washington Post, implored staff to destroy sensitive materials using incinerators, disintegrators and “burn bins” present in the compound. The directive also called for the destruction of “embassy or agency logos, American flags, or items which could be misused in propaganda efforts.”

The State Department has said the embassy will remain open but most of its functions and personnel are expected to be moved to Hamid Karzai International Airport to prepare for a potential evacuation.

In Washington, the department’s Diplomatic Security Bureau began preparing for a crisis, calling on volunteers with “High Threat, High Risk” and overseas experience for “potential 24/7 operations supporting U.S. Embassy Kabul,” per a separate memo sent to staff.

“The whole thing is about to go bad,” said one State Department official who works on security issues. Like others, this official spoke on the condition of anonymity to discuss a tenuous, evolving situation.

With just weeks to go before the U.S. military is scheduled to conclude its withdrawal under a firm Aug. 31 deadline set by President Joe Biden, the United States and its allies are dispatching thousands of troops to Kabul to help evacuate their citizens as embassy operations are scaled back or temporarily halted.

The Biden administration is sending an additional 3,000 soldiers and Marines to boost security while civilian staff from the U.S. Embassy depart along with Afghans who have aided the U.S. war effort. A first wave of Marines arrived at the Kabul airport Friday, Pentagon spokesman John Kirby told reporters. Additional personnel were expected to follow soon, he added, saying, “We will be able to move thousands per day.”

With time running out to whisk away Afghans under threat of reprisal for working with the United States, the State Department is making a last-minute push to secure agreements with countries to temporarily house Afghans. U.S. diplomats are discussing a potential agreement to safely harbor at-risk Afghans in Kosovo and Albania where they would be vetted under the Special Immigrant Visa program before resettling in the United States, said a diplomat familiar with the situation. The frantic effort, first reported by Reuters, follows stalled discussions with the Central Asian nations of Kazakhstan, Tajikistan and Uzbekistan, where the Biden administration hoped to send thousands of SIV applicants.

All of the U.S. combat units shuttling into Afghanistan to aid with the evacuations were already in the region, accelerating the military’s response time. They include two Marine infantry battalions from Camp Lejeune in North Carolina and Camp Pendleton in Southern California, and a combined-arms Army battalion reinforced with soldiers from the Minnesota National Guard, U.S. officials said.

Britain has said it will deploy 600 troops to facilitate the departure of British nationals as its embassy in Kabul is reduced to a “core team focused on providing consular and visa services for those needing to rapidly leave the country,” officials said. Canada also will send military personnel to help evacuate embassy staff. Young children of Afghans who worked for Canada are among those sheltering there, hopeful that they, too, will be rescued, Canadian news outlet Global News reported.

India’s embassy in Kabul issued its second security advisory in as many days calling on its citizens to make immediate arrangements to leave the country. Norway and Denmark, who share a diplomatic compound in Kabul, said they would shutter their embassies for now.

The Taliban’s latest advances come despite an appeal from the United States and its international partners for the warring Afghan parties to advance peace talks launched last year. Those negotiations have not progressed as hoped.