Chuck Hagel must be wondering why he ever agreed to accept President Obama’s controversial nomination to be America’s defense secretary. Not only did he have to endure an agonizingly difficult — and bitterly partisan — confirmation process on Capitol Hill, he is now dealing with Afghanistan’s Hamid Karzai.

On Sunday, soon after Hagel arrived in his country, the Afghan leader accused the American military of fueling violence in collusion with the Taliban. Why in the world would the Americans do such an outrageous thing? Karzai told his television audience it is because they are seeking to justify a prolonged presence in his country.

That, of course, flies directly in the face of Obama’s oft-repeated pledge to withdraw all American troops from Afghanistan by next year, even though Obama’s timetable raises serious questions about Afghanistan’s ability to defend its own interests without direct military assistance from Washington.

Karzai also said, incidentally, that foreign troops were harassing Afghan university students.

To be fair, there may be some truth in what the Afghan leader said Sunday. Most Americans, who may be predisposed to dislike Karzai, are nevertheless in no position to judge the accuracy of his accusations. But it is clear that Karzai’s criticisms came at an extremely awkward time, given that they coincided with Hagel’s first overseas trip in his new capacity.

The Afghan political leader has long been a thorn in the side of the Obama administration, even as the United States and NATO forces have been fighting to preserve the very freedoms that keep Karzai in office, so his behavior this past weekend wasn’t particularly surprising.

But Hagel deserved a far more cordial welcome from a leader who has benefited so much from the involvement of the United States in his country’s defense. It is well known there is a culture of corruption in Afghanistan’s government and little evidence that Karzai has been able, or even willing, to put an end to it, so he’s not exactly a sympathetic figure.

Instead of being diplomatic, Karzai was loudly critical of policies that Americans insist are among the most important to their mission in Afghanistan, including widespread deployment of Special Operations forces and retaining a role in vetting and releasing suspected enemy troops.

Karzai went further, excluding American commandos from one Afghan province and criticizing an agreement on how Bagram Prison will be managed after Americans leave. Because of those criticisms, on Saturday the Americans abruptly refused to hand over full control of the prison.

Admittedly, Karzai has to walk the line between being too opposed to his key allies, and too close to the Americans, who are, after all, invaders. It is not surprising that as the Obama-set withdrawal deadline nears, he is increasingly setting himself up as in opposition to the NATO coalition. This appears mostly to be a PR offensive for his countrymen. By contrast, the U.S.-led NATO coalition is stuck with Karzai, and Hagel must pick up the pieces created by Karzai and try to put a good face on a difficult relationship with an ungrateful ally.

Hagel and Karzai later dined together, and the former Republican senator described their discussion in positive terms.

“I know these are difficult issues for President Karzai and the Afghan people,” he said. “And I was once a politician, so I can understand the kind of pressures especially leaders of countries are always under.”

If Hagel knew pressure as a senator, he’s learning that as defense secretary it takes on an entirely new tone. Even his critics on Capitol Hill must be sympathetic.