Updated

Four-star general-turned-CIA director David Petraeus almost resigned as Afghanistan war commander over President Barack Obama's decision to quickly draw down surge forces, according to a new insider's look at Petraeus' 37-year Army career.

Petraeus decided that resigning would be a "selfish, grandstanding move with huge political ramifications" and that now was "time to salute and carry on," according to a forthcoming biography.

Author and Petraeus confidante Paula Broadwell had extensive access to the general in Afghanistan and Washington for "All In: The Education of General David Petraeus," due from Penguin Press in January. The Associated Press was given an advance copy.

The book traces Petraeus' career from West Point cadet to his command of two wars deemed unwinnable: Iraq and Afghanistan. Co-authored with The Washington Post's Vernon Loeb, the nearly 400-page book is part history lesson through Petraeus' eyes, part hagiography and part defense of the counterinsurgency strategy he applied in both wars.

Critics of counterinsurgency argue the strategy has not yet proved a success, with violence spiking in Iraq after the departure of U.S. troops, and Afghan local forces deemed ill-prepared to take over by the 2014 deadline.

The book unapologetically casts Petraeus in the hero's role, as in this description of the Afghanistan campaign: "There was a new strategic force released on Kabul: Petraeus' will."

Broadwell does acknowledge that Petraeus rubs some people the wrong way.

"His critics fault him for ambition and self-promotion," she writes. But she adds that "his energy, optimism and will to win stand out more for me."

The book also is peppered with Petraeus quotes that sound like olive branches meant to soothe Obama aides who feared Petraeus would challenge their boss for the White House.

"Petraeus tried to make clear that he and Obama were in synch," Broadwell writes of Petraeus' Senate testimony on the Afghan war.

The book describes Petraeus' frustration at still being labeled an outsider from the Obama administration, even as he retired from the military at Obama's request before taking the job last summer as the CIA's 20th director.

The book depicts Petraeus' rise at an unrelenting, near-superhuman pace. He starts his career as a fiercely competitive West Point cadet known as "Peaches," where he famously wooed the school superintendent's daughter, Holly Knowlton. He went on to command the 101st Airborne Division as part of the invasion of Iraq, then masterminded the rewrite of the Army and Marine Corps' counterinsurgency training manual before returning to command the surge in Baghdad. He was then appointed to head Central Command, overseeing the campaigns in Iraq and Afghanistan as well as military affairs across much of the Gulf and the Mideast.

He accepted a cut in authority and pay to lead the Afghanistan war campaign when Gen. Stanley McChrystal was forced to resign after a Rolling Stone article that "scorched the general (McChrystal) and his aides, caricaturing them as testosterone-addled frat boys as they insulted Obama" and other officials, Broadwell writes.

She describes how Petraeus' first act was to lift McChrystal's restrictions on the use of force -- especially on airstrikes -- if civilians were nearby.

"There is no question about our commitment to reducing civilian loss of life," Petraeus told his staff. There was, however, "a clear moral imperative to make sure we are fully supporting our troops in combat."

Broadwell adds that the problem, according to Petraeus, was less McChrystal's order than how it was even more strictly re-interpreted by lower commanders.

In her account, Petraeus also faults McChrystal for overpromising and underdelivering in places like Taliban-riddled Marjah in the south, producing months of embarrassing headlines that hurt the war effort back in Washington.

But the book also includes Petraeus' own Rolling Stone-esque moment, when he was quoted badmouthing the White House in Bob Woodward's latest book, "Obama's Wars." A frustrated Petraeus is described as telling his inner circle, on a flight after a glass of wine, that "the administration was (expletive) with the wrong guy."

"Petraeus later expressed his displeasure to all of them for betraying his confidence," Broadwell wrote. "But he knew he was ultimately responsible for making the intemperate remark," a candid admission, through Broadwell, of his lapse in judgment.

He also concedes the Afghan war is not yet won.

"He had wanted to hand (Marine Corps Gen. John) Allen ... a war that had taken a decisive turn," Broadwell writes of what had been Petraeus' goal for his successor. "He knew that, despite the hard-fought progress, that wasn't yet the case."

Yet that admission also presents a get-out clause when combined with the book's account that he considered resigning over the rapid drawdown of troops, neatly removing Petraeus from responsibility if the war goes wrong.

And the account does nothing to puncture the mythology his troops built up around him, something an early mentor, retired Gen. Jack Galvin, told Petraeus to embrace.

"They want you to be bigger than you are, so they magnify you," Galvin said in an interview with Broadwell. "Live up to it all with the highest standards of integrity. You become part of a legend."

"All In" fits neatly into that.