Afghan President Hamid Karzai’s agenda interferes with President Obama's political aims of ending the war smoothly. (MOHAMMAD ISMAIL/Reuters)

In early 2009, as Afghanistan’s second presidential election loomed, President Hamid Karzai described his once-genial relationship with the United States as a “gentle wrestling match” that he hoped to win.

Four years later, another Afghan election is nearing, and that match has become far more grueling — a sometimes blistering fight that Karzai waged this month with a flurry of public statements and speeches. But this time, the invective is bolder and the stakes are higher, as Karzai interferes with President Obama’s political aims of ending the Afghanistan war smoothly.

In recent weeks, Karzai has accused the United States of collaborating with the Taliban, torturing Afghan civilians, kidnapping university students and deliberately violating his country’s sovereignty by attempting to undermine Afghan institutions.

Karzai, who has no clear political rival, has said he will retire when his second term ends in 2014, as mandated by the Afghan constitution. But Afghan officials say the president’s public excoriation of the United States is a strategic move in a different campaign, one he fears losing: shedding his domestic image as an American puppet and establishing himself as an autonomous leader

Karzai is convinced, Afghan officials say, that publicly establishing his sovereignty will help him garner the support he needs to sell a partnership with the United States to the Afghan public, paving the way for the presence of American troops beyond 2014. Without such an agreement, political instability and deteriorating security could prompt the reemergence of ethnic and political factions, including some who count Karzai as an enemy and would like to see him dead.

“We need the people’s support,” said Aimal Faizi, Karzai’s spokesman, explaining the logic behind some of the recent statements. “We need that support in order to sign the bilateral security agreement.”

If that is Karzai’s aim, it is often hard to discern from his words. His public remarks are filled with insouciance toward a long-term agreement — a clear message that he has no attachment to U.S. forces if they don’t play by his rules.

Karzai seems eager to prove that he is willing to stomach an Afghanistan without foreign troops if it means that he’ll have proved his independence. The man who came to power thanks to American support would then leave behind a far different legacy, as officials close to him see it — that of a strong, sovereign Afghan leader “working for his own people,” Faizi said.

Recent interviews with Karzai’s top advisers have yielded the same brand of defiance. Even as foreign troop levels and billions of dollars in aid hang in the balance, Karzai’s presidential palace believes it has more leverage than the White House or NATO.

“For signing an agreement with the United States, we may pay a very high price,” said Abdul Karim Khurram, Karzai’s chief of staff, alluding to the possibility that such a deal could galvanize the insurgency and upset Iran and Pakistan.

Pulling the plug

Karzai’s hostility has been criticized by political rivals, and many U.S. and Afghan officials see his position as misguided and untenable. Some U.S. officials and politicians say there’s a limit to how much of Karzai’s acerbic rhetoric and misleading public accusations they can handle.

“I am perfectly capable of pulling the plug on Afghanistan,” Sen. Lindsey O. Graham (R-S.C.), long an advocate of a robust U.S. presence, told Foreign Policy magazine last week.

With Karzai’s critiques vacillating between specific points of contention and sweeping attacks, some U.S. officials wonder whether there is a basic strategic misalignment between him and the Americans as they head into the endgame.

“If it’s a strategic problem and it’s just getting worse, that needs to be addressed before we can dive back into technical issues,” said a senior Obama administration official, who, like others quoted in this report, was not authorized to speak on the record.

Karzai’s Afghan critics say his fixation on lambasting the West comes at the cost of more important domestic problems that he has ignored, such as corruption and ineffective local governance. They worry that alienating the United States will lead to the total withdrawal of foreign troops and a more dangerous Afghanistan. Although Karzai’s popularity varies across the country, concerns about Afghanistan after 2014, when the vast majority of foreign troops are due to leave, are pervasive.

“His statements and actions are not in the interest of Afghanistan, and we do not share his assessment or his opinion,” said Hanif Atmar, Karzai’s former interior minister. “Our advice to him is not to put relationship with our best allies at risk.”

Some of Karzai’s political opponents have voiced concern that the absence of foreign oversight would help Karzai either stay in office beyond 2014 or manipulate the election results so that he can effectively choose his successor. Karzai vehemently denies those accusations, but even national political figures have expressed concern about announcing their candidacy until his intentions become clearer.

Deals blocked

U.S. officials here have refrained from castigating Karzai publicly. Instead, they say, they have looked for ways to make quiet progress on some of Karzai’s key criticisms, namely the failure to hand over the Parwan military detention center and the presence of U.S. Special Forces in volatile Wardak province.

“We believe communications on sensitive issues such as the Parwan detention facility or Wardak are best done in private, without the added pressure of media coverage that can paint people into positions that are ultimately unhelpful,” said Col. Thomas Collins, a spokesman for U.S. forces in Afghanistan.

U.S. officials have enlisted emissaries trusted by both Karzai and the United States. Ashraf Ghani, a former finance minister and World Bank economist, was chosen as a go-between on the detention center negotiations. Abdul Rasul Sayyaf, a former mujaheddin commander, was recruited to help settle the Wardak issue.

But neither has made progress. When Ghani arrived at the presidential palace the day before Parwan was scheduled to be transferred to Afghan control, Karzai rejected the compromise he had arranged. And Karzai has not relented publicly on his demand to remove U.S. Special Forces from Wardak, despite Sayyaf’s efforts.

The takeaway for some U.S. officials was that even constructive negotiations led by seemingly influential Afghans can be rendered worthless when it comes time for Karzai’s final authorization. That has worrisome implications for the bilateral security agreement, now being negotiated by another emissary, Afghanistan’s ambassador to the United States, Eklil Ahmad Hakimi.

“Karzai is concerned with his legacy, but he can’t have his cake and eat it, too. He’s relying on the West to defend him from ­al-Qaeda . . . but he’s single-handedly endangering his key lifeline to the West,” a former senior U.S. official said.

But Karzai has resolved to speak loudly about issues while they are negotiated, Faizi said.

“When we are not being heard in private meetings, it is then that the president comes to speak to the people,” Faizi said.

That attitude isn’t new for Karzai. For years, he publicly criticized the United States for its apparent lack of concern for civilian casualties and its unilateral night operations. On both issues, Karzai saw progress. The U.S. military started paying more attention to civilian deaths, which dropped considerably, and night operations are now crafted and led by Afghans.

Some Afghans say Karzai’s ability in the past to get what he wants from the United States has energized his current willfulness.

“He is used to getting what he asks for, and so he keeps demanding more,” one senior Afghan official said.

But Karzai’s supporters say their president isn’t just playing politics. At heart, he’s a dovish leader charged with governing during a war now in its 12th year, they say. When groups of Afghans gather in his palace meeting rooms to complain about what they perceive as American abuses, Karzai responds viscerally and angrily. The strident public statements quickly follow.

“The U.S. is a superpower and Afghanistan is a poor country,” Faizi said, “but to the president, that doesn’t mean our sovereignty shouldn’t be taken seriously.”

Karen DeYoung in Washington contributed to this report.