Robert Gates and President Obama salute during a farewell ceremony for Gates as outgoing defense secretary. Gates served in that position under Obama and President George W. Bush. He was known as a savvy manager of the bureaucracy and a ruthlessly efficient defense secretary. In his new memoir, Gates asserts that Obama had more than doubts about his course in Afghanistan.

June 30, 2011 Robert Gates and President Obama salute during a farewell ceremony for Gates as outgoing defense secretary. Gates served in that position under Obama and President George W. Bush. He was known as a savvy manager of the bureaucracy and a ruthlessly efficient defense secretary. In his new memoir, Gates asserts that Obama had more than doubts about his course in Afghanistan. Evan Vucci/AP

Greg Jaffe covered the Pentagon for The Washington Post and is a co-author of “The Fourth Star: Four Generals and the Epic Struggle for the Future of the United States Army.”

Maybe it was the time of year, just before the Christmas holidays. Maybe it was the setting — a bare-bones combat outpost in the violent mountains of eastern Afghanistan. Maybe it was the strain of more than four years of signing deployment orders that he knew would lead to the deaths of more young Americans. But in December 2010, speaking to troops clustered around him, Robert M. Gates was overcome by an uncharacteristic flood of emotion.

The soldiers in their dirt-splattered uniforms had been ordered to stop whatever they were doing and listen to the defense secretary, who, with his neatly parted white hair, khakis and starched button-down shirt, looked as if he had helicoptered in from another planet. “I feel a personal responsibility for each and every one of you,” Gates said. “I feel the sacrifice and hardship and losses more than you’ll ever imagine. I just want to thank you and tell you how much I love you.”

It is impossible to imagine former wartime defense secretaries Donald Rumsfeld, Dick Cheney or Robert McNamara ever telling his troops that he loved them.

As a military reporter who covered Gates throughout his nearly five-year tenure and witnessed many of his increasingly emotional thank yous to troops in Afghanistan, I often wondered what was going on inside his head: He rarely showed anger or frustration. “I have a pretty good poker face,” he explains in his new memoir, “Duty.”

“Duty: Memoirs of a Secretary at War” by Robert M. Gates. (Knopf)

While his rivals at the White House, the State Department and the Pentagon loudly staked out their positions, Gates held back his opinion. The uncertainty about where he stood was a source of his power, allowing him to swoop in at the last moment and broker a bargain, usually on terms that were most acceptable to him. Unlike his predecessors, he had a reputation for quietly and ruthlessly holding subordinates accountable. He fired senior people, including Gen. David McKiernan, his top wartime commander in Afghanistan, whom Gates thought wasn’t up to the job — the first such dismissal since the Korean War.

In his new book, which has nearly 600 pages of text, Gates takes the reader inside the war-room deliberations of Presidents George W. Bush and Barack Obama and delivers unsentimental assessments of each man’s temperament, intellect and management style. “It is difficult to imagine two more different men,” Gates writes.

Gates left Washington in 2011 with a reputation as a steady, sober-minded member of the foreign policy establishment who had served eight presidents and was admired equally by Republicans and Democrats. The next time Gates visits the capital, his reception may not be quite so warm. “Duty” is his second memoir, and this time he cuts loose.

He slams Congress for its grandstanding and gridlock. “I would listen with growing outrage,” he writes, “as hypocritical and obtuse American senators made all these demands of Iraqi legislators and yet themselves could not even pass budgets.” He describes members of the House Foreign Affairs Committee as “rude, nasty and stupid.”

Joe Biden haters will enjoy Gates’s description of the vice president as loud, garrulous and obsessed with politics over substance. “I think he has been wrong on nearly every major foreign policy and national security issue over the past four decades,” Gates writes. He accuses the vice president of poisoning Obama’s relationship with his generals: “I thought Biden was subjecting Obama to Chinese water torture, every day saying, ‘the military can’t be trusted.’ ”

Gates admires Obama’s decisiveness and smarts, but accuses him of sending troops to fight and die in support of a strategy in Afghanistan that, according to Gates, the president himself believed would fail. “I never doubted Obama’s support for the troops, only his support for their mission,” Gates writes.

He recounts his thoughts during a tense 2011 meeting with Obama and Gen. David H. Petraeus, then in charge of U.S. and NATO forces in Afghanistan, in the White House Situation Room: “As I sat there I thought: The president doesn’t trust his commander, can’t stand Karzai, doesn’t believe in his own strategy and doesn’t consider the war to be his. For him, it’s all about getting out.”

The critique will infuriate the parents and spouses of troops who were killed trying to execute Obama’s Afghan war strategy. But Gates doesn’t prove his damning accusation and can be maddeningly self-contradictory in his criticism of Obama. He describes the president’s decision to send 33,000 more troops to Afghanistan as courageous and politically unpopular. “Obama overruled the policy and domestic political concerns of his vice president and virtually all the senior White House staff,” Gates writes. Why would the president pursue a politically unpopular strategy that he believed would fail? Gates never attempts to explain the contradiction.

Though he decries Obama’s White House staff as the “most centralized and controlling” since the Nixon administration, he offers little substantive criticism of the president’s big decisions on Afghanistan. Hawkish Republicans and some in the military slammed Obama for putting firm limits on the number of troops he was willing to send to Afghanistan and for setting a withdrawal date, saying the timelines and troop caps betrayed a lack of resolve and emboldened the enemy. Gates, however, dismisses this argument, writing, “I believe Obama was right in each of these decisions.”

Gates’s problem with the president is less about strategy or substance than about heart. “I myself, our commanders, and our troops had expected more commitment to the cause and more passion for it from him,” Gates writes. He compares Obama unfavorably with Bush, who “had no second thoughts about Iraq, including our decision to invade.”

No civilian in Washington was closer to the wars in Iraq and Afghanistan than Gates. As Washington and the rest of the country were growing bored with the grinding conflicts, he seemed to feel their burden more acutely. He describes how his trips to Afghanistan and Iraq wore on him: “On each visit I was enveloped by a sense of misery and danger and loss.” His anger at Obama, Congress and even some in the Pentagon seems to spring from his belief that they didn’t match his sense of mission in Afghanistan. They didn’t feel the sting of the troops’ deaths with the intensity that he felt.

More than 3,800 soldiers and Marines died on Gates’s watch in Iraq and Afghanistan. The losses are small compared with the numbers in the Civil War, World War II or Vietnam. But for Gates and his generals, they were extraordinarily difficult to bear. Gates spent most of his evenings as defense secretary alone, writing condolence letters to the families of the deceased. He asked his staff for a picture of the soldier and some hometown news clippings so that he would be able to personalize his message. It was a major change from the early days of the war, when Rumsfeld relied on an autopen machine to sign the letters — a practice he abandoned after lawmakers publicly flayed him for it.

Like Gates’s profession of love for the troops in Konar, his descriptions of the guilt and pain he felt from these losses are touching, heartfelt and occasionally a little over the top, especially when he recounts his predawn jogs around the Mall in Washington: “I would ritually look up at that stunning white statue of Lincoln, say good morning, and sadly ask him, How did you do it?”

McNamara published his autobiography, “In Retrospect,” two decades after the Vietnam War as a kind of pre-death-bed confession. “We were wrong, terribly wrong,” he wrote of his and his colleagues’ mistakes. Rumsfeld’s autobiography, “Known and Unknown,” was fueled by his desire to settle scores with his Bush administration foes and shoot back at critics of his tenure as defense secretary.

Gates, widely considered the best defense secretary of the post-World War II era, seems to have been driven by a desire to sort through all of the anger, frustration, sadness and guilt that he held inside during his tenure. The book comes off a bit like an extended therapy session.

In public Gates was always polite and in control. His private and deep sense of obligation to the men and women he was sending to war made him an effective defense secretary. He fought to buy special mine-resistant vehicles for U.S. troops in Iraq and Afghanistan over the objections of many of his generals, who didn’t want to spend the money. He forced the Air Force to scale back its plans to buy high-tech fighter jets and instead to boost spending on surveillance drones that were desperately needed in Iraq and Afghanistan.

He insisted that the military add field hospitals and helicopters in Afghanistan to ensure that every wounded soldier or Marine would receive treatment within an hour of his injuries. Military doctors insisted that two hours was fast enough. Gates imagined a wounded soldier waiting for a helicopter in the dirt and dust, and told the military doctors and generals to make it an hour.

There are moments when Gates seems to realize that he let his pain, guilt and frustration overwhelm his judgment in the latter days of his tenure. “My fuse was really getting short,” he writes. “It seemed like I was blowing up — in my own, quiet way — nearly every day, and no longer just in the privacy of my own office with my staff.”

Like most soldiers, journalists and civilians who passed through Iraq and Afghanistan, Gates still seems to be struggling to make sense of his war years and the toll they took on him. He says he is “indescribably proud” of the U.S. military’s efforts to stem the chaos in Iraq and believes that the American war effort in Afghanistan is on a path to reasonable success. He also carries the heavy burden of knowing that troops were killed and maimed following his orders.

This confusing, frustrating and sometimes fascinating book is best summed up by a pair of conflicting statements Gates uttered during his tenure. In a meeting with Obama’s national security team a few days before the president’s inauguration, Gates described being defense secretary as “the most gratifying experience of my life.” Only days earlier, in an e-mail to a friend, he confided: “People have no idea how much I detest this job.”

greg.jaffe@washpost.com

Greg Jaffe covered the Pentagon for The Washington Post and is a co-author of “The Fourth Star: Four Generals and the Epic Struggle for the Future of the United States Army.”