Secretary of State Mike Pompeo, left, and John R. Bolton, the national security adviser, had differing views on the peace plan. Credit:Erin Schaff/The New York Times Trump made no decision on the spot, but at some point during the meeting the idea was floated to finalise the negotiations in Washington, a prospect that appealed to the President's penchant for dramatic spectacle. Trump suggested that he would even invite President Ashraf Ghani of Afghanistan, whose government has not been party to the talks, and get him to sign on. In the days that followed, Trump embraced an even more remarkable idea — he would not only bring the Taliban to Washington, but to Camp David, the crown jewel of the American presidency. The leaders of a rugged militant organisation deemed terrorists by the US would be hosted in the mountain getaway used for presidents, prime ministers and kings just three days before the anniversary of the September 11, 2001, attacks that led to the Afghan war. Thus began an extraordinary few days of ad hoc diplomatic wrangling that upended the talks in a weekend Twitter storm. On display were all of the characteristic traits of the Trump presidency — the yearning ambition for the grand prize, the endless quest to achieve what no other president has achieved, the willingness to defy convention, the volatile mood swings and the tribal infighting. What would have been one of the biggest headline-grabbing moments of his tenure was put together on the spur of the moment and then cancelled on the spur of the moment. The usual National Security Council process was dispensed with; only a small circle of advisers was even clued in.

And even after it fell apart, Trump took it upon himself to disclose the secret machinations in a string of Saturday night Twitter messages that surprised not only many national security officials across the government but even some of the few who were part of the deliberations. Almost a done deal For Trump, ending the war in Afghanistan has been a focus since taking office, a signature accomplishment that could help him win reelection next year. For nearly a year, Khalilzad, a former ambassador to Afghanistan, has engaged in talks with the Taliban to make that happen. In recent weeks, it had been increasingly clear that the US and the Taliban, after nine rounds of painstaking negotiations in Doha, Qatar, had ironed out most of the issues between them. Khalilzad declared that the agreement document had been finalised "in principle." The deal called for a gradual withdrawal of the remaining 14,000 US troops over 16 months, with about 5,000 of them leaving within 135 days. In return, the Taliban would provide counter-terrorism assurances to ease American fears of a repeat of September 11 from Afghan soil.

But the negotiations left out Afghanistan's government, and Ghani's officials criticised it for lacking measures that would ensure stability. At home, Trump was cautioned by Senator Lindsey Graham; General Jack Keane, a retired Army vice chief of staff; and General David Petraeus, the retired Afghanistan and Iraq commander. Bolton was the leading voice against the deal on the inside as Pompeo's allies increasingly tried to isolate the national security adviser. Bolton argued that Trump could pull out 5,000 troops while still leaving enough forces to assist counter-terrorism efforts without a deal with the Taliban, a group he argued could not be trusted. In an interview on Sunday, Graham said he shared Trump's desire "to end the war in Afghanistan between the Taliban and the Afghan people." But he added that no deal could include withdrawing all US forces or trusting the Taliban to confront al-Qaeda or the Islamic State. "My advice to the administration is, let's focus on trying to shore up our relationship with Pakistan," he said, adding that it should include a free-trade agreement. He said that the Taliban must be prevented from believing it can seek safe harbour in Pakistan. Zalmay Khalilzad, the top American negotiator in talks with the Taliban, at the US Embassy in Kabul. Credit:New York Times

A dividing point When Khalilzad left Doha after the last round of talks concluded September 1, two days after the Situation Room meeting, he and his Taliban counterparts had finalised the text of the agreement, according to people involved. Leaders of both teams initialled their copies and handed them to their Qatari hosts. Before the end of the meeting, Khalilzad brought up the idea of a Taliban trip to Washington. Taliban leaders said they accepted the idea — as long as the visit came after the deal was announced. That would become a fundamental dividing point contributing to the collapse of the talks. Trump did not want the Camp David meeting to be a celebration of the deal; after staying out of the details of what has been a delicate effort in a complicated region, Trump suddenly wanted to be the dealmaker who would put the final parts together himself, or at least be perceived to be. The idea was for Trump to hold separate meetings at Camp David with the Taliban and with Ghani, leading to a more global resolution.

Even as talks were wrapping up in Doha, the US ambassador to Afghanistan arrived at the presidential palace in Kabul with the proposal of a Camp David meeting, Afghan officials said. Details were sorted out between the Afghan president and the American side when Khalilzad arrived from Doha and held four rounds of talks with Ghani. A plane would arrive to take Ghani and his delegation to the US, according to the initial plan. Ghani's ministers knew that a Taliban delegation would most likely be arriving, too, but were unclear on the details. They had three priorities: the fate of presidential elections scheduled for September 28, how the peace talks would move forward to include them and how they would bolster security forces to reduce the cost for the US. As a sign of how important the event was for the US, Ghani got the Americans to agree to include on the trip his national security adviser, Hamdullah Mohib, who had essentially been kept out of the American meetings after lashing out at the peace process. For months, the Americans had essentially held Ghani's reelection campaign hostage to a deal that they projected was imminent. Ghani was reduced to pretending that the September elections were still on by holding a couple of daily "virtual rallies" at which he addressed small gatherings around the country via video chat. If the US-Taliban deal were finalised, it would most likely push the elections back.

If Ghani had refused the Camp David meeting, he would have been called a spoiler of peace, a senior Afghan official said. So he took his chances; it was to be hosted by an ally on friendly turf, and it could help clarify whether there would be a peace deal, and whether the elections would proceed. Intensifying bloodshed But Taliban leaders, having refused to negotiate directly with the Afghan government until after the group had an agreement with the US, said the Americans were tricking them into political suicide. A senior Taliban leader said on Sunday that Trump was fooling himself to think he could bring the Taliban and Ghani together at Camp David "because we do not recognise the stooge government" in Kabul. The Americans were also rushing to finalise outstanding issues in the days before the last-minute proposed Camp David meeting. Among the most significant was a disagreement over the release of thousands of Taliban prisoners in Afghan prisons.

Afghan officials said the Americans had taken the liberty of negotiating on their behalf by agreeing to the release. Ghani's government found that unacceptable, saying it would agree only if the Taliban reciprocated with an extensive cease-fire — something the insurgents are reluctant to do at this stage of the talks since violence is their main leverage. Loading The final negotiations occurred during a period of intensifying bloodshed. In response to Taliban attacks, US negotiators made clear they were prioritising the agreement, not looking to boycott the talks. Their negotiations were undergirded by increasing battlefield pressure by the US military. When Khalilzad and General Austin S. Miller, the US commander in Afghanistan, returned to Doha on Thursday, it was to finalise technical appendices to the main text. The Taliban negotiators got no sense that anything was amiss and later posted on Twitter that the atmosphere was good. But the same day, aides told Trump about a suicide car bomb attack that killed a US soldier and 11 others. At this point, according to senior officials, Trump and his team were unified. He could not host Taliban leaders at Camp David just days after an American was killed.

"This is off; we can't do this," Trump told his aides, according to one official. No announcement was made by the White House. In Kabul on Friday, Ghani's officials told reporters that he planned to travel to the US, and then hours later said he would not go. But little was made of that at the time. The endgame of the talks seemed near, if not the timetable. Only then came Trump's tweets on Saturday night disclosing that he had invited the Taliban and Ghani to Camp David — but called it off, citing the bombing. The tweets took many in the administration by surprise; there was no reason for Trump to reveal what had happened, several officials said, especially since he has not given up on the idea of a negotiated settlement. Hours later, Pompeo visited Dover Air Force Base for the arrival of the coffin of Army Sergeant 1st Class Elis Angel Barreto Ortiz, who was killed in the Kabul bombing. His presence was unusual for a secretary of state; the return of fallen US soldiers would be more traditionally attended by presidents or defence secretaries.