U.S. officials must be heartily sick of Afghan President Hamid Karzai, whose latest wheeze has been to announce that a vital deal to retain a long-term U.S. military presence in his country cannot be signed until after elections next year.

In response, President Barack Obama’s administration has said it needs a finished deal by the end of 2013. No doubt waiting until May to begin preparations for the stay-behind force would be hard. Mainly, though, the U.S. ultimatum appears designed to push back against Karzai’s heavy-handed tactics.

The agreement, which was announced this week, would enable about 10,000 U.S. troops to remain in Afghanistan after the main allied force withdraws next year, training and supporting the newly built Afghan army as it takes on the Taliban alone. When Karzai presented the draft agreement to the tribal loya jirga yesterday, he recommended its approval, but said he wouldn’t sign it until after presidential elections in April -- in part because he didn’t trust the U.S., which had made “propaganda” about him.

Afghanistan’s loya jirga and parliament must decide for themselves whether they will be better off with or without U.S. military support. The U.S., however, shouldn’t bind itself to ultimatums that will put its policy into the hands of the erratic, lame-duck president. The test of this agreement’s value should be whether it contributes to the U.S.’s long-term security goals. So it’s important keep in mind what those are.

The draft Security and Defense Cooperation Agreement posted on the Afghan foreign ministry’s website would enable a limited U.S. force to stay in Afghanistan until 2024. That presence is designed to ensure that the Taliban doesn’t re-establish itself, possibly returning the country to a radical Islamist state and a haven for terrorist groups such as al-Qaeda. A smaller counterterrorist force would remain to help fight any remnants of al-Qaeda, now much debilitated and based in Pakistan.

These two goals were worth fighting for in 2001, and they are today, even with a price that could reach $10 billion a year, more than half of which would go to funding and equipping the Afghan National Army. That’s a lot of money, given neglected U.S. commitments elsewhere, but the alternative is a resurgent conflict, a revived al-Qaeda, lost progress and diminished U.S. leverage. You don’t have to go far to imagine what that would look like -- it’s a description of Iraq, where the U.S. failed to agree a continued military presence after withdrawal.

Ultimately, 10,000 to 15,000 foreign troops can’t be expected to defeat the Taliban where as many as 140,000 failed. Yet a U.S. stay-behind force is the best among imperfect alternatives and consistent with allied strategy in Afghanistan to date: to build an Afghan army that can keep the peace when international forces leave. Commitment to a longer-term U.S. military presence, with the air power and logistical support that entails, might convince Taliban leaders that they can’t win against this new army either, and should consider peace talks.

A U.S. presence would also help with the effort to persuade Pakistan and Afghanistan to a more stable rapprochement. And it might persuade the warlords in Kabul to stop rebuilding private armies against the day when the central government begins to crumble. You would think that Karzai would value these goals, too.

One of the few British survivors of the First Anglo-Afghan War scathingly described the 1839-1842 campaign as “a war begun for no wise purpose, carried on with a strange mixture of rashness and timidity, brought to a close after suffering and disaster, without much glory.” The hope that U.S. soldiers don’t end up with a similarly brutal verdict after retiring defeated from this “graveyard of empires” rests on staying to help the Afghan army survive.

To contact the Bloomberg View editorial board: view@bloomberg.net.