No peace deal is perfect, and the “Agreement for Bringing Peace to Afghanistan” is no exception to that rule. But it is the beginning of a much-delayed diplomatic process to bring an end to America’s longest — and most unpopular — war. Trump tried and failed to do it in 2019. In 2020, he may have succeeded.

Officially entitled “ Agreement for Bringing Peace to Afghanistan ,” this three-part, four-page document guarantees a timeline of 14 months for the “complete withdrawal” of all U.S. and NATO troops from Afghanistan; a Taliban pledge that “Afghan soil will not be used against the security of the United States and its allies”; the launch of intra-Afghan negotiations by March 10; and a “permanent and comprehensive” ceasefire.

But credit where credit is due. Over the weekend, at the Sheraton hotel in Doha, Qatar, the Trump administration was able to achieve in its first term what the Bush and Obama administrations were either unable or unwilling to do over two terms each: Sign a peace deal with the Taliban.

I never imagined I would ever write these three words. It pains me, in fact, to see them on the page.

Don’t get me wrong: I have no doubt that if Barack Obama had signed such a deal with the Taliban, he would have been pilloried by the same Republican politicians and Fox News pundits now cheering Trump’s agreement. Obama, for example, was scorned and slammed for releasing five Taliban detainees in exchange for a captured U.S. soldier, Sgt. Bowe Bergdahl, in 2014; Trump, on the other hand, has agreed to the release of an astonishing 5,000 Taliban prisoners.

I am also aware that Trump has never been consistent on Afghanistan, nor does he give a damn about ordinary Afghans. He has cut U.S. aid to the country; bragged about dropping the “mother of all bombs” on it; pardoned two U.S. army officers accused of committing war crimes in Afghanistan; and casually and repeatedly discussed killing millions of Afghans, including in his speech to the Conservative Political Action Conference on Saturday. Last year, according to the U.N., there were more than 10,000 civilian casualties in Afghanistan, with around a quarter of them killed or wounded by the U.S. military and its allies. Their blood is on Trump’s hands — in the same way that the blood of thousands of Afghan civilians killed and injured between January 2009 and January 2017 is on Obama’s.

For far too long, Iraq was the “bad war” and Afghanistan the “good war.” Yet there was nothing “good” about the decision to invade and occupy Afghanistan. None of the 19 hijackers were Afghans. The 9/11 plot was hatched in Hamburg, Germany, not Kabul or Kandahar. Yes, there were Al Qaeda training camps in Afghanistan but the Taliban, lest we forget, had agreed to hand over Osama bin Laden to a third country, on the condition that the United States provided some evidence of his guilt. The Bush administration refused.

Nevertheless, in September 2001, there was massive support across the political spectrum for attacking the Taliban in Afghanistan. The vast majority of Americans backed Bush’s decision to invade and believed it would end in victory. So did the New York Times editorial board. The only member of Congress to oppose the conflict was the indomitable Rep. Barbara Lee, who warned of the danger of embarking “on an open-ended war with neither an exit strategy nor a focused target.”

Nearly two decades later, it is difficult to overstate what a catastrophic disaster this particular “open-ended war” has been — both for the American and Afghan peoples. Where to begin? Some 2,400 American soldiers killed and more than 20,000 wounded. More than 58,000 Afghan security forces killed. More than 100,000 Afghan civilian casualties. More than half the population below the poverty line. More than $2 trillion spent. A quadrupling in opium production. Endemic corruption. War crimes. The cover-up of child sexual abuse. The rise of ISIS in Afghanistan. The list goes on.

Today, the Taliban control or contest nearly half the country’s districts which, according to data from the Pentagon, is “more territory … than at any point since 2001.” Meanwhile, five months after the Afghan presidential election, the official winner Ashraf Ghani is still trying to form a government while his main rival Abdullah Abdullah has declared himself the victor, crying “fraud” and “treason” in the process.

It wasn’t only the Iraq invasion that was defined by official deceit and dishonesty. As a damning investigation by the Washington Post, based on leaked government documents, revealed in December 2019, “senior U.S. officials failed to tell the truth about the war in Afghanistan throughout the 18-year campaign, making rosy pronouncements they knew to be false and hiding unmistakable evidence the war had become unwinnable.”

Those who now line up to criticize or condemn Trump for trying to end this “unwinnable” war have yet to grapple with the shocking revelations contained in these “Afghanistan Papers.” Trump, of course, isn’t interested in peace — or the truth. The U.S. president craves a photo op with Taliban leaders and knows that he also needs a diplomatic win. Above all else, he hopes to use a U.S. troop withdrawal from Afghanistan to bolster his prospects for reelection in November.

But guess what? Sometimes bad people do the right thing for the wrong reasons. Yes, Trump is an awful president and an even more awful person. But just as only Nixon could go to China, perhaps only Trump could do this historic deal with the Taliban.

As political scientist Barnett Rubin, who has advised both the U.S. State Department and the United Nations on Afghanistan, told me, “no rational, conventional, predictable U.S. politician would take the political risks needed to negotiate seriously with the Taliban.”

Will a deal between the two sides hold? Can either Trump or the Taliban be trusted to stick to the terms of the agreement? Does it give away too much to the insurgents, in return for too little? Maybe. The bigger question, according to International Crisis Group President Robert Malley, is: What’s the alternative?

“The fact that the Taliban got so much out of the deal is not, primarily, a result of anything the Trump administration did,” Malley told me. “It is because, after two decades, the U.S. has failed to win an unwinnable war.”

For Malley, who was a senior foreign policy adviser to Obama, “it would have been far preferable if a deal had been reached years ago, when the Taliban were in a weaker position” but it would be “far worse if a deal were not reached now, based on the illusory belief that, somehow, the Taliban will be in a weaker position tomorrow.”

As with Iran and the nuclear agreement, though, there are plenty of hawks in Washington, D.C., who still want to hold out for a better deal in Afghanistan.

They’re deluded.

For a deal to work, it requires agreement on all sides. “A ‘better deal’ that one side rejects is not a deal at all, but a dream of a better world,” said Rubin. “We all have such dreams, but eventually we have to wake up.”

Unless, he added, “we are dead.”