Afghanistan’s President Hamid Karzai has capped an erratic career by denouncing an agreement with President Obama that he himself negotiated, calling the United States an obstacle to peace and jeopardizing a NATO plan for assuring the security and the economy of his nation in coming years.

Mr. Karzai recently called a meeting of 3,000 Afghan leaders in a traditional Afghan “loya jirga” assembly to advise him on signing the agreement to allow perhaps 10,000 to 15,000 American and NATO logistics and counter-terror troops and advisors to remain in Afghanistan after December 2014, when all American and NATO combat forces are scheduled to leave.

The “status of forces” agreement is the key to continued allied financial support and advice without which the Afghan armed forces and the Afghan economy would collapse.

Washington has advised Mr. Karzai that if the agreement is not signed by the end of the year, it will be obliged to begin planning a complete withdrawal.

The “loya jirga” overwhelmingly supported the agreement, recognizing that Afghanistan’s hopes for peace and prosperity rest on the continuing support of the United States and NATO.

But Mr. Karzai rejected the advice of the council of elders he had convened, and began making vague new conditions, saying he would not sign the agreement until the United States produced peace in Afghanistan.

“I have no idea what he means. Nobody does,” Karzai’s former deputy defense minister Atiqullah Baryalai told the Los Angeles Times.

“This president — I don’t have any idea what he’s doing,” Azrakhsh Hafizi, a loya jirga committee chairman who also directs the Afghanistan International Chamber of Commerce in Kabul, said in an interview with the Times. “Presidents come and go, but the people are the owners of this country. He should listen to them.”

John Podesta, a former White House chief of staff for Bill Clinton who advises President Obama on Afghanistan, said the Afghan president has become increasingly “erratic.” Afghan observers say he has lost the respect of the Afghan people.

If Mr. Karzai has chosen to be contradictory and recalcitrant as a negotiating strategy, it is difficult to see what he hopes to achieve. Any personal agenda he may have pales in comparison to the needs of his nation.

Mr. Karzai has said he wants the next president, to be elected in April, to sign the agreement. That is four months later, at least, than the date the White House says is essential for forward planning.

Mr. Obama may be tempted by the unpopularity of the American military mission in Afghanistan to take Mr. Karzai’s refusal as a reason to pull all American troops out by the end of next year, leaving the Afghans to their fate.

Faced with a similar impasse in Iraq, that is exactly what he did, to the continuing regret of most Iraqis who face a resurgent civil war.

But the prospect of an Afghanistan that becomes again a failed nation and refuge for terrorists argues strongly for staying the course and finding a way to keep some allied troops in Afghanistan.

Mr. Obama has to find a way around Mr. Karzai to make that possible.