Doha: It seemed a thankless and impossible assignment: negotiating a deal with the Taliban that offers the United States an exit from its longest war.
But Zalmay Khalilzad, the Afghan-born American envoy and architect of the deal, drew on everything he had to pull it off: broad autonomy from his bosses in Washington, nearly four decades of experience in US academia, government and diplomacy, and a lifetime of dealing with tumultuous Afghan politics.
A year and a half of difficult - often criticised - diplomacy, under a ticking clock set by President Donald Trump, had brought success where several previous attempts at a peace between the United States and the Afghan insurgents failed. The historic deal sealed on Saturday paves the way to start a gradual withdrawal of American forces from Afghanistan.
A key difference in what Khalilzad was willing to do was this: He moved to talk with the Taliban directly, hear them out at length, and agree to their divisive demand to discuss a troop withdrawal without the US-allied Afghan government at the table.
And more, he pushed to define who would be at that table.
After nearly a decade stuck in a Pakistani jail, Mullah Abdul Ghani Baradar, the Taliban's deputy chief, had returned to pick up the insurgent group's case in large part because of Khalilzad's ability to put the weight of American diplomacy behind his release.
As soon as Baradar arrived in Doha, Qatar, to lead his side, Khalilzad put another tool to test - his charm. He sought to put the Taliban leader at ease, something on display throughout the process even during some of the most tense moments in the negotiation
The two men began small group discussions and Khalilzad, who is fluent in local languages, would speak to Baradar in Pashto.
They often met in Baradar's room at the venue for the talks, a posh resort where vacationing Russian couples sunbathed by the pristine pool outside and a musician played the piano in the lobby under a large chandelier.
"This must be the closest you have come to heaven," Khalilzad joked with Baradar during one of those early meetings. Baradar quickly closed the curtains.
On Saturday, right before signing the deal, Baradar glanced at Khalilzad, who was seated next to him, and the two men nodded with subdued smiles.
Khalilzad, 68, arrived in the United States as an immigrant teenager when the upheaval in Afghanistan started, and as President George W. Bush's ambassador to the United Nations, he was the highest-ranking Muslim in the US government when he left office.
That he would gamble his legacy on resolving a conflict that had stymied many other seasoned diplomats left many wondering whether this was done at least somewhat out of personal obligation.
Here was a man who had become the diplomatic face of two of America's most contentious involvements in the Muslim world in recent times, serving as the cleanup ambassador after the invasions of Iraq and Afghanistan.
He even had an advising role in the Reagan administration as the United States abandoned Afghanistan after supporting guerrillas who were fighting the Soviets. Khalilzad has written critically of how that was handled in the end: It helped drive Afghanistan into the chaos that groups like al-Qaida subsequently exploited.
James Dobbins, a former American special envoy to Afghanistan and Khalilzad's one-time boss, said a sense of regret over that abandonment has perhaps reaffirmed Khalilzad's commitment. When Bush appointed him as ambassador to Afghanistan in 2003, he conditioned his acceptance on a larger aid package for the impoverished country.
"He has a unique combination of experience with American national security and American diplomacy and Afghanistan," Dobbins said. "There is no one who knows more players and influential figures in Washington and Kabul than Zal Khalilzad."
Even before he returned to government to lead the Afghan talks, Khalilzad, a member of the Republican national security elite, had for years been in Trump's orbit - even if on its outer rings.
In April 2016, the three-time ambassador was asked to introduce Trump ahead of the then-presumptive Republican presidential nominee's first foreign policy speech - to bring "gravitas" to the Washington event. His appearance set off speculation that he was angling for a diplomatic post, or a Cabinet position, inside a Trump administration.
But he did not rejoin the State Department until September 2018, when he became one of only a half-dozen of Secretary of State Mike Pompeo's envoys granted broad autonomy. Pompeo assiduously promoted his efforts.
When Congress demanded briefings on the Afghan peace talks, Pompeo blocked that to protect Khalilzad's tightly guarded process.
For a period early in the process, it felt as if Khalilzad had a free hand in how he shaped the deal. But once Trump got more involved directly, the envoy went largely silent in public.
In September, just as Khalilzad was on verge of finalizing his deal, Trump abruptly called off talks. Publicly, the president cited the Taliban's continuing attacks. But part of the reason appeared to be the Taliban's refusal to agree to his grand gesture of a meeting at Camp David before an American troop withdrawal was announced.
Zal and his team really grappled, after the September decision to break off Taliban talks, with how to keep it on life support.
"Zal and his team really grappled, after the September decision to break off Taliban talks, with how to keep it on life support," said Dan Feldman, who served as special representative to Afghanistan and Pakistan under President Barack Obama.
"Many would have been tempted to leave at that point, feeling that more than a year of hard work was thrown overboard," said Dobbins, who had been Bush's Afghanistan envoy. "His ability to stick with it, and to persuade the Taliban to give some additional concessions, was a real credit."
A key hand in helping put the talks back on track was Robert C. O'Brien, the White House national security adviser. He took that post in the tumultuous stretch when the negotiations had been called off and John Bolton, who had advocated against the deal, was fired.
In an interview on Sunday, O'Brien said he and Khalilzad were close after working together on several hostage release efforts over the years.
"After negotiations had broken down, Secretary Pompeo, Ambassador Khalilzad and I worked together to see if it was possible to get the negotiations back on track, to get the Taliban to show their good faith and wanting to return to the table," O'Brien said. "I think those efforts were successful, and ultimately we got a deal."
In addition to the American troop withdrawal, that deal also ensures ending terror sanctuaries in Afghanistan and starting negotiations between the Afghan sides over a power sharing government - something that could end the insurgency altogether.
Khalilzad continued shuttling the world on his mission, balancing skeptical allies, clashing interests, and a multitude of potential spoilers. Wherever he is, he "tends to take up all the oxygen in the room," a senior administration official said.
In the Afghan capital, Kabul, some at the US Embassy referred to him as "Hurricane Zal." When he is on the ground, it is events and meetings around the clock - at the ambassador's residence, on rooftops of politicians over traditional delicacies, or even in the mansions of warlords in faraway provinces.
The government of President Ashraf Ghani in Afghanistan has remained deeply suspicious of him throughout the talks, despite Khalilzad's history with Ghani dating back to their teenage years when both were students on study-abroad programs in the United States.
'Charmed by the Taliban'
Ghani's officials often described the American envoy as being vague on details of what they feared might be concessions he was making to the Taliban, such as promises of prisoner releases - something under the authority of the Afghan government.
They would say he had been charmed by the Taliban. (Khalilzad has called Baradar an "Afghan patriot" in interviews.)
Ghani's national security adviser even went as far as telling the media in Washington that Khalilzad was trying to negotiate a future government with the Taliban "of which he will then become the viceroy."
In essence, Khalilzad has been juggling several negotiations at once - discussions with an extremely divided Afghan political elite in Kabul, shuttle diplomacy with countries of a region in turmoil, and talks with the Taliban insurgents in Doha.
Long drawn-out sessions
Once the Taliban came to the table, the problem was not just the deep mistrust. There was also the challenge of negotiating complicated legal texts with a group that, when in power, had run a government through basic chits. It required a lot of explaining to the Taliban, for example, that their demands - among them dismantling in a matter of months a military presence of 18 years - were logistically not possible. Much of that work fell on Khalilzad's deputy, Molly Phee, also experienced in negotiating with irregular forces in places like Iraq and Sudan.
Some sessions dragged on as long as 16 days, with talks regularly going past midnight. During breaks, Khalilzad was often out on his phone, one hand on his ribs. He mingled easily with the Taliban negotiators, cracking jokes, giving a pat on the back in passing. Many of them called him "Dr. Saeb" - or "Doctor Sir." - out of respect. (Khalilzad has a Ph.D. in political science from University of Chicago.)
But in session, the talk was often tough, with negotiations frequently coinciding with an uptick in violence back in Afghanistan. On several occasions early in the process, Khalilzad got into shouting matches over the violence with the Taliban's deputy negotiator who led the day to day, Sher Mohammad Abas Stanekzai.
Stanekzai, in response, would point to American airstrikes.
"And it is not your village that is being bombed," he responded in one session, according to officials briefed on the talks.
In the end, the relationship Khalilzad and Baradar developed was instrumental for troubleshooting when negotiators got stuck. The two chiefs met at least a dozen times one on one or accompanied by just a few others.
When the signing ceremony commenced on Saturday, in a ballroom packed with nearly a dozen foreign ministers and at least 10 rows of other dignitaries and Taliban members, the two men took their seats at the desk.
Baradar wore a black turban, his reading glasses and a small shawl around one shoulder. Khalilzad was in a blue suit and maroon tie.
They exchanged quiet, easy smiles. But this day, the Taliban chief was taking no chances. He watched closely until the American envoy signed first, seemingly unwilling to put pen to paper until he was sure there was no trick.
After the ceremony, the usually animated Khalilzad walked quietly down the steps, and into the hallway, the copy of the agreement he put his signature - and legacy - to tucked under his arm.