Afghan President Hamid Karzai, already seen as an untrustworthy irritant by the Obama administration, startled the world by balking -- at the last second -- over signing a post-war security pact with the United States.

The controversial leader is cementing his reputation as unreliable, raising the stakes during a recent face-to-face meeting with National Security Adviser Susan Rice.

Karzai told Rice he would not sign the bilateral-security agreement defining the U.S. role in Afghanistan after 2014 unless the White House agrees to a new set of last-minute demands, including expanded peace talks with the Taliban and the release of 17 Afghan terror suspects from Guantanamo Bay.

Never mind that Karzai is asking President Obama to do the impossible when it comes to detainees. Obama has spent years trying to repatriate Gitmo inmates to their home countries only to have Congress block those efforts.

At first, the administration believed Karzai was merely posturing and buying time to show the Taliban and other anti-U.S. elements in Afghanistan that he could stand up to the U.S. After all, the text of the agreement was settled after an arduous year-long negotiation and approved by a council of Afghan elders.

“It's Hamid Karzai just trying to show people that he's in charge — a lot of this is just posturing,” said Sterling DeRamus, an attorney and retired Navy officer who served as command historian in Afghanistan under Gen. David Petraeus in 2010. “He's raising a lot of very old points that have always been raised.”

DeRamus was referring to Karzai's request for further guarantees that U.S. forces will not raid Afghan homes, after a number of civilian deaths sparked local protests. Obama addressed the issue of raids in a letter to Karzai that was also read to the Loya Jirga, the Afghan assembly that endorsed the security pact.

But Karzai has remained intransigent, and his latest theatrics have U.S. patience wearing thin.

The White House pushed back, with Rice demanding Karzai sign the agreement by December or suffer the consequences, including the possibility that the U.S. will pull all troops out of Afghanistan and withhold billions in financial aid.

The administration hopes to leave a residual force of 8,000 to train Afghan military forces and safeguard humanitarian operations after the war.

The threat to pack up and leave could also endanger Karzai's personal security. The Afghan leader cannot run in April’s presidential election because of term limits, but he hopes to cement his legacy by ensuring the victory of a hand-picked successor. The campaign could leave him vulnerable to assassination attempts without crucial U.S. security and financing.

The greater fear though may be that Karzai’s high-stakes gamble unravels the over decade-long international effort to build a stable Afghanistan.