(CNN) The US military negotiated a secret arrangement with the Taliban that resulted in members of the militant group escorting clusters of Americans to the gates of the Kabul airport as they sought to escape Afghanistan, two defense officials told CNN.
One of the officials also revealed that US special operations forces set up a "secret gate" at the airport and established "call centers" to guide Americans through the evacuation process.
While one of the military officials said the arrangement with the Taliban "worked beautifully," Americans involved in an unofficial network dedicated to helping Americans and vulnerable Afghans said there were problems -- particularly in the beginning -- as the Taliban turned away US citizens and legal permanent residents the militant group was supposed to allow through.
The two US defense officials said Americans were notified to gather at pre-set "muster points" close to the airport where the Taliban would check their credentials and take them a short distance to a gate manned by American forces who were standing by to let them inside amid huge crowds of Afghans seeking to flee.
The US troops were able to see the Americans approach with their Taliban escorts as they progressed through the crowds, presumably ready to intervene in case anything happened.
Multiple sources in the US who were in contact with people trying to escape reported that American citizens and passport holders in Kabul were in disbelief that they were being told they would receive safe passage from the Taliban. Many thought they were misunderstanding the directions and sought clarification.
The stateside sources said they had to assure those attempting to use a muster point at the Ministry of Interior Affairs that the Taliban would indeed allow them through.
The two US defense officials spoke on the condition of anonymity due to the sensitivity of the arrangements, which have not been disclosed until now because the US was concerned about Taliban reaction to any publicity, as well as the threat of attacks from ISIS-K if its operatives had realized Americans were being escorted in groups, the officials said.
The ISIS offshoot, a sworn enemy of the Taliban, claimed responsibility for a suicide attack at a gate to the Kabul airport last week that killed 13 American service members and more than 170 Afghans.
The US has had military and diplomatic contact with the Taliban for years through political talks and deconfliction efforts, but the secret evacuation arrangement between the militant group and the US military reflects an unprecedented level of tactical coordination. While it's not known whether there is any connection, CIA Director William Burns paid a highly unusual visit last week to Kabul, where he met with Taliban leader Abdul Ghani Baradar as the Biden administration struggled to get airlift operations running smoothly.
Throughout the evacuation, Biden administration officials stressed that the Taliban were cooperating and senior officials repeatedly emphasized that the militant group had committed to provide "safe passage" for Americans.
The Taliban escort missions happened "several times a day," according to one of the officials. One of the key muster points was a Ministry of Interior building just outside the airport's gates where nearby US forces were readily able to observe the Americans approach. Americans were notified by various messages about where to gather.
"It worked, it worked beautifully," one official said of the arrangement.
But Americans who created an unofficial network to help Afghans and Americans find a route out of Afghanistan heard differently from the vulnerable men, women and families they were trying to guide to safety.
In some instances, Americans and green card holders were turned away at the Interior Ministry muster point during the course of evacuations, according to people in the network who were in touch with several Afghans attempting passage through the secret route.
In one instance, the network described failed escape attempts where several US citizens and legal permanent residents, or green card holders, were denied access by the Taliban at the Interior Ministry rendezvous point.
It's unknown how broadly the Taliban's refusal to admit some people with passports or green cards into the Interior Ministry muster point affected US efforts to evacuate those people as they tried to escape Kabul.
US forces and officials were not present at the muster point and CNN is relying on reports from American officials off site, from people who attempted passage and their stateside contacts, including family members, former military and intelligence officials and others who lent support to Afghan Americans and Afghans attempting escape.
It's also unclear if Americans and green card holders who got turned away at the Interior Ministry eventually made it to the airport during subsequent attempts at passage through the ministry or through another route to the airport.
At least one American citizen turned away at the muster point had to secure an alternative way to enter the airport for himself and his family, which included children, according to one network of Americans supporting other Americans and Afghans trying to escape.
Another family of six green card holders, including small children, was turned away at the muster point but was able to gain entry at the Interior Ministry muster point another night. Their family member in the US reported that once they arrived at the airport, they lined up in an organized fashion to show their documents and were processed in an orderly manner.
That family flew from Kabul to a US base overseas in a flight facilitated by the US military and are awaiting return to the United States.
Initially, the process for getting people evacuated through the Interior Ministry muster point was bumpy, according to one network of US-based Americans who were communicating with a green card holder in Kabul who exited via the rendezvous point early on.
That American resident, along with family members, including at least one US citizen, waited for several hours with the Taliban at the muster point along with more than 20 other families.
There was confusion that night, one of the first nights the Interior Ministry was used, as armed Taliban took possession of American passports, green cards and cell phones, and the group of more than 100 Americans and passport holders and their family members huddled in the cold for several hours at the muster point, according to multiple members of the network who were assisting in the situation. Eventually the documents were returned and the group made its way to the airport.
The process became smoother as coordination between the US and Taliban played out over many nights, people in the unofficial network said.
As of Monday, when the US completed its withdrawal, more than 122,000 people in total had been airlifted from Hamid Karzai International Airport since July and more than 6,000 Americans civilians evacuated.
In another separate secret arrangement not disclosed until the operation was over, troops from the elite Joint Special Operations Command and other special operations units were also on the ground helping Americans escape by contacting them through "call centers," one of the officials said.
Special operations forces set up their own secret gate at the airport and were at times in direct communication with Americans telling them exactly where to walk to find the gate and be able to get inside the airport.
The secret gate allowed the US military to offer some protection to Americans by avoiding the publicly known and highly vulnerable gates to Afghanistan's only airstrip for international flights.
As the evacuation got underway, thousands thronged to the airport gates hoping to get inside and onto flights, raising concerns about a terrorist attack focused on one of those entrances.
On Sunday, August 22, as he confirmed his decision not to extend the evacuation deadline beyond August 31, President Joe Biden acknowledged the growing threat ISIS-K posed to the airport.
"Every day we're on the ground is another day we know that ISIS-K is seeking to target the airport and attack both US and allied forces and innocent civilians," Biden said.
Last Wednesday, a US defense official told CNN that based on a very specific threat stream, it seemed clear that ISIS-K planned to attack crowds outside the airport. The US Embassy in Kabul warned US citizens at airport gates to "leave immediately" and noted "security threats outside the gates."
On Thursday, the ISIS offshoot struck with its suicide bomber.
Commander of US Central Command Gen. Frank McKenzie first publicly revealed the involvement of special operations forces at a Monday press conference saying those forces helped evacuate more than 1,000 American citizens and more than 2,000 Afghans "via phone calls, vectors, and escorting."
Special operations forces "reached out to help bring in more than 1,064 American citizens and 2,017 SIVs or Afghans at risk, and 127 third-country nationals all via phone calls, vectors, and escorting," he said. But in public comments, McKenzie did not specify the involvement of JSOC which includes forces that carry out the most dangerous counterterrorism missions such as the Army's Delta Force and Navy SEALS.
This story has been updated with additional reporting.