LONDON—The Afghan government of President Ashraf Ghani had a feeling, based on long experience, that peace negotiations between the Trump administration and the Taliban would not go well. But then, Ghani didn’t have much to say about it.

The U.S.-backed government in Kabul was shut out as Donald Trump’s envoy struggled to reach a deal in direct talks with the Taliban over the course of nine long rounds, mostly in Qatar. The Ghani government was only informed about bits and pieces of the program when Trump’s people thought it convenient or, indeed, when the talks appeared to be reaching a conclusion.

But the dynamics were obvious to Afghans on all sides, even if most Americans were not paying much attention: Trump is torn between his desire to get all U.S. troops out of Afghanistan so he can declare an end to what has come to seem an endless war, and his desire to appear a winner in the conflict.

Unfortunately, the terms of any deal with the Taliban discussed so far are likely to make that impossible. And late on Saturday night, Trump erupted on Twitter. “Unbeknownst to almost everyone,” he said, Taliban leaders “were going to secretly meet with me at Camp David on Sunday." But “in order to build false leverage, they admitted to an attack in Kabul that killed one of our great great soldiers,” Trump declared, so he, “immediately canceled the meeting and called off peace negotiations.”

As often happens, Trump’s tweets provoked more questions than they answered. In fact, the administration is still trying to work out a new formal meeting between U.S. officials and the Taliban, according to two individuals with direct knowledge of the conversations.

But wait—the Taliban terrorists were to come to Camp David?

That’s right. The idea could have been useful political theater, and Secretary of State Mike Pompeo said as much in a series of Sunday morning talk shows. Trump’s Camp David show would have harked back to the diplomatic triumph of President Jimmy Carter, who negotiated an end to the seemingly endless conflict between Egypt and Israel in 1978.

True, the Taliban had long protected Osama bin Laden and they still think the Al Qaeda attacks on New York and Washington 18 years ago this week were a great triumph, but the optics of “Donald Trump’s Camp David” presumably had won out in the president’s mind. At least at first.

“ We know the history of Camp David. We reflected on that as we were thinking about how to deliver for the American people. ” — Secretary of State Mike Pompeo

“Who thought it was a good idea for the President of the United States to meet with Taliban leaders, who have the blood of thousands of Americans on their hands, just three days before 9/11?” Chris Wallace asked Pompeo on Fox News.

“We know the history of Camp David,” Pompeo said. “We reflected on that as we were thinking about how to deliver for the American people.”

Although only last week the U.S. negotiator had announced an “agreement in principle,” this not-so-secret meeting might have offered a chance for Trump to show off the art of the deal. According to Pompeo, Trump said, “I want to talk to President Ghani. I want to talk to these Taliban negotiators. I want to look them in the eye. I want to see if we can get to the final outcome that we needed so that we could sign off on that deal.”

By delivering a mostly pre-cooked Afghan accord at Camp David, Trump could have signed the agreement with his now-famous Sharpie and claimed it was bigger, better, the best, the most beautiful… we all know how that goes.

But the Taliban just wouldn’t let him get away with the kind of language and spectacle he wanted. They kept insisting on a complete and explicit timeline for the “evacuation,” as they put it, of all U.S. personnel. The American withdrawal supposedly would be conditional on their actions, but they knew that as U.S. support for the Afghan government waned, the insurgents could expect government troops and security forces to quit fighting them or, indeed, join them. The fiction of peace with honor could fall apart badly a year from now, at the height of the U.S. presidential campaign.

Hard to make that look like a win for Trump.

But as a tactical matter, maybe the Taliban should cut him a break, and maybe they have realized that now.

A senior official in the Kabul government told The Daily Beast he expects, “Sooner or later peace talks will start up again, but with a much different attitude. The Taliban really proved they don’t know the language of international diplomacy. The tone the Taliban are using with the Americans is like the tone they use when talking to the Afghans,” meaning the weak government. “The Taliban understanding of negotiations is very limited and blurry. They are expert in basic warrior language, but have a very poor command of political or diplomatic vocabulary.”

“ It had always been understood that both sides would continue fighting until an actual ceasefire agreement was signed. ”

This official with the Kabul government said that President Ghani’s tolerance when he was excluded from the bilateral U.S.-Taliban talks had proved wise, since the Taliban had overplayed their hand and Trump had called off the talks. “With a single tweet, the Taliban tumbled from the sky to the earth,” said the official.

In any case, they were surprised.

Taliban sources told The Daily Beast everything seemed to be going well and on schedule for an announced agreement until about 11 p.m. Saturday, which would have been about 4 p.m. at the Trump golf club where the president was staying in Sterling, Virginia.

It was true, these Taliban sources said, that the chief U.S. negotiator, Ambassador Zalmay Khalilzad, was “extremely unhappy” with the latest Taliban suicide bombing in Kabul in which U.S. Army Sergeant 1st Class Elis A. Barreto Ortiz, 34, from Puerto Rico, was killed along with 11 other people. Sixteen U.S. troops have been killed in Afghanistan this year.

But it had always been understood that both sides—the Taliban and the Afghan government forces backed by devastating U.S. airpower—would continue fighting until an actual ceasefire agreement was signed.

Then came the Trump tweets, claiming the death of Sgt. Ortiz was the reason for calling off the agreement.

“We were stunned,” said one senior figure in the Taliban hierarchy. “It’s like being stuck in a roundabout [traffic circle] with many red and green lights and having no idea in what direction to move.”

The Taliban negotiators went into an urgent meeting in Qatar “to measure and assess the latest developments,” this source said. “Did Trump mean this as a joke or seriously? Or just a technique to pressure the Taliban at the last minute?”

What came out was a statement in what was, for the Taliban, pretty diplomatic language.

President Trump’s invitation to the Taliban negotiators to visit the United States had been extended at the end of August, they said, but the Taliban put it off until an agreement was ready to sign.

Preparations for that were well under way, the Taliban statement said, and the date of Sept. 23 had been set for them to start—at last—their negotiations with the Kabul government.

The Taliban said they would give “precedence” to talks over war, but Trump’s “reaction towards a single attack just before the signing of an agreement displays [a] lack of composure and experience.” They noted that the U.S. and those it backs in Afghanistan have done plenty of killing as well. As The Daily Beast reported last week, moreover, the U.S. Department of Defense may not come close to counting all those civilians who die in American air strikes.

The Taliban statement concluded: “Our previous 18-year resistance should have proven to America that we will accept nothing less than the complete end of occupation and allowing Afghans to decide their own fate. And we shall continue our Jihad for this great cause and maintain our strong belief in ultimate victory, Allah willing.”

In Trump’s choleric tweets calling off the previously secret Camp David event, he asked of the Taliban, “How many more decades are they willing to fight?”

They continue to be confident of the answer: many more decades than the Americans.

POSTSCRIPT: According to the New York Times, the agreement with the Taliban had been finalized and initialed, apart from some technical appendices, which did not raise problems. A Camp David meeting was not needed. But Trump wanted a show: "Mr. 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, Mr. Trump wanted to be the dealmaker who would put the final parts together himself, or at least be perceived to be."

Sami Yousafzai reported from London and Christopher Dickey from New York. Erin Banco also contributed reporting from Washington D.C.