Afghan President Hamid Karzai is up to his elbows in Iranian cash, using bribes from Tehran to help buy the loyalty of friends and rivals.

Every other month, The New York Times reports, Iran sends over about $1 million to $2 million, which Karzai and his chief of staff dole out to maintain power over a network of tribal leaders, government officials and Taliban warlords.

Karzai’s in bed with the US for much more than Tehran dishes out, but Iran’s gifts are entirely off the books — literally delivered, as they are, in bags.

“We have no choice but to be friendly with Iran,” said Afghanistan’s finance minister.

Friendly ain’t the half of it.

Iran’s meager millions have bought it unfettered access to Karzai’s presidential palace, even as it finances, trains and arms some Taliban factions.

Meanwhile, US Ambassador Karl Eikenberry is waging a personal war against Karzai, publicly suggesting he’s a manic depressive whose ties to America are as fickle as his mood swings.

A competent administration would keep Karzai in line: He was installed at the tip of NATO’s spear in 2001 and has since been propped up by American troops and aid.

It’s hard to believe the US is incapable of managing this rag doll who owes his political and financial fortunes to the US. But relations with Karzai have deteriorated under Obama.

It doesn’t matter whether it’s America’s fault. It’s Obama’s responsibility to ensure Karzai doesn’t fall into Iran’s pocket or cut a deal with the Taliban that makes America’s nine-year fight all for naught.

American public opinion, already flagging badly regarding the war, will be further strained: US combat fatalities are running at the rate of two a day, while graft and treachery chugs along virtually in broad daylight.

Once upon a time, Obama could legitimately have blamed all of this on his predecessor. No longer.

It was Obama in 2008 who declared that winning the Afghanistan war was a vital American interest — and he inherited Karzai going on two full years ago.

There are no easy answers — there never are — but if the White House can’t even keep its client Karzai under control, what hope is there that it can grapple successfully with less tractable regional actors?