After almost 18 years of war, the United States may finally be on the verge of withdrawing from Afghanistan.

Opponents of an Afghan withdrawal or even drawdown justifiably point to the clear limits of the proposed deal U.S. envoy Zalmay Khalilzad has negotiated with the Taliban: The Afghan government has been sidelined, a cease-fire could prove transitory and the Taliban could renege on any pledge to renounce al-Qaida. Yet there is also a clear reason for such an unsatisfactory agreement. Despite nearly two decades of fighting — and overwhelming superiority in manpower, firepower and money — the U.S. has remarkably little leverage in Afghanistan.

The security situation is the worst it has been since the U.S. invasion in 2001. Though the U.S. stopped releasing district stability data this year, independent analysts conclude that the Taliban controls or contests the majority of Afghanistan's districts. Civilian casualties in 2018 were twice what they were during even the worst years of Afghanistan's brutal 1990s civil war. Most importantly, the Afghan National Security Forces are taking unsustainable casualties and attrition, as both Afghan and U.S. military leaders concede. Over a third of the Afghan National Army must be replaced every year.

All of this comes despite another grim metric: The U.S. dropped more bombs in Afghanistan in 2018 than in any previous year.

The Trump administration's "mini-surge," foisted on a clearly reluctant president by his military advisers, has failed. All major security indicators have stalled or moved in the wrong direction. Even the instruments of this escalation, the Army's vaunted Security Force Assistance Brigades, are struggling, with noncombat attrition rates as high as those of their Afghan partners.

American leverage is also affected by both its looming presidential election and President Donald Trump's clear enthusiasm for withdrawal, but these are both secondary factors. The major reason the U.S. finds itself picking between a bad deal with the Taliban and no deal at all is the foolish groupthink of the U.S. foreign policy and military establishment. Despite ample evidence that nation-building in Afghanistan was a fool's errand, devoted followers of respectable foreign-policy opinion obstinately insist that the U.S. persists with a failed Afghan strategy regardless of the country's cultural, geographic, political and military realities. The U.S. has spent more on Afghan reconstruction than it did on the entire Marshall Plan in Europe — but has precious little to show for it.

For most of the last two decades, the U.S. has thrown good money after bad in Afghanistan. That includes expanding NATO's mission in Afghanistan in 2006, surging troops and promising "government in a box" under Gen. Stanley McChrystal and President Barack Obama, or dropping the so-called Mother of All Bombs under Trump. Now reduced to merely fighting not to lose, the limits of American power and expertise are plain for all to see. Victory is always said to be just around the corner — and still could be, according to some in Washington who refuse to face reality.

Had the U.S. negotiated with the Taliban in 2003, 2009 or 2017, it could hardly have gotten a worse deal than it stands to achieve today. But there were always talking heads, purported experts and armchair strategists eager for escalation, not to mention generals who wanted to prove their mettle. Yet with nearly 2,500 American troops killed and more than $1 trillion squandered in an attempt to fix one of the most backward countries on earth, America is further than ever from building a peaceful democracy in Kabul.

Both voters and veterans realize this: Nearly 60% of both groups say the Afghan war was not worth fighting, according to a recent Pew Research Center survey.

The U.S. has little leverage as the country enters what may be the stretch run of negotiations to end its military role in Afghanistan. The U.S. refusal to negotiate and accept more realistic goals, even at moments of temporary battlefield advantage, has left Khalilzad with a weak hand, despite all the blood and treasure expended.

There's a saying in American infantry battalions, usually directed by furious sergeants at slow-moving privates: "Play stupid games, win stupid prizes." A nearly 18-year military campaign in Afghanistan has been a very stupid game, and leaving with a fig leaf agreement is the fittingly stupid prize. Should U.S. troops stay longer, whatever the justification, our negotiating position will not be improved. A bad deal or no deal are the options America's bipartisan foreign policy establishment has left us with in Afghanistan.

Gil Barndollar is a senior fellow at Defense Priorities and the military fellow-in-residence at the Catholic University of America's Center for the Study of Statesmanship. From 2009-16 he served as an infantry officer in the Marines and deployed to Afghanistan, Guantanamo Bay, Cuba, and the Persian Gulf. He wrote this article for the Los Angeles Times.