Robert Gates’ Duty: Memoirs of a Secretary at War, is the most peculiar book of its kind that I’ve read in a long time, maybe ever. It’s a fascinating, briskly honest account of one dyspeptic yet steely man’s journey through the cutthroat corridors of Washington and world politics, with shrewd, sometimes eye-popping observations along the way about the nature of war and the limits of power. It’s also a primal scream unleashed at those who got in his way (i.e., endangered the nation), and, like most primal screams, it’s dripping with earthy wisdom but also maddening inconsistencies.

Gates was a truly historic secretary of defense, the only one who’s served under consecutive presidents from opposing parties (George W. Bush’s last two years, Barack Obama’s first two) and one of two—the other being Robert McNamara—who transformed the Pentagon in turbulent times.

I covered the span of Gates’ tenure in my Slate columns, wrote his first big profile (in the New York Times Magazine), and interviewed him a few subsequent times (for Foreign Policy and my book, The Insurgents). His memoir provides a panoramic, high-res picture of the man that my articles could only roughly sketch. He was a patrician-statesman, perhaps the last such hybrid, who felt a noblesse oblige to public service. But he was also a career intelligence officer who shimmied up the ropes from junior analyst to CIA director and, in the process, acquired a glint in his eye and a retractable dagger in his heel. He knew how to insinuate his views into a discussion without leaving fingerprints behind, and he could calmly toss obstructionists overboard if necessary.

This book has shocked many erstwhile colleagues and admirers who’d regarded him all these years as a mild-mannered, bipartisan healer—when, in fact, beneath the calm façade displayed at congressional hearings, diplomatic dinners, and NSC meetings, he was “seething” with contempt, “running out of patience,” “fed up,” or often just plain “bored.”

The veteran Washington insider Norman Ornstein told Foreign Policy that the book’s sour attitude and indiscretions could “tarnish” Gates’ “entire reputation.” My guess is, if Gates read this remark, he chuckled and muttered that he doesn’t give a flying fuck (yes, he talks that way in private) what the likes of Norm Ornstein think of his reputation.

Gates seems to have written this book in part to dissuade any politician from asking him to join an administration ever again. Certainly, it’s hard to imagine any president hiring such a covert loose cannon for any top-level job—and that’s fine with Gates. “I did not enjoy being secretary of defense,” he writes at one point. At another, he recalls telling a friend in an email, “People have no idea how much I detest this job.”

News stories about Duty have highlighted Gates’ criticism of Obama and his White House staff. I will deal with that in a moment, but it’s first worth noting that he is far more critical of George W. Bush’s policies (though, significantly, less so of Bush personally). He bashes Bush’s “freedom agenda” as “too simplistic” and his lofty goals in the Afghanistan war as “embarrassingly ambitious (and historically naïve).” He believes that the invasion of Iraq and the revelations about renditions, Abu Ghraib, and Guantánamo “fueled further anti-American feeling.” He describes himself as “stunned” by the Bush administration’s “bungling” of the first few years of the Iraq war and occupation.

Dick Cheney comes in for harsher licks (though, again, with a soft brush). Cheney, he recounts, pushed for military force as a first option in nearly every crisis, especially over Syria and Iran—while Gates considered force as the last option, at most. (“One thread running through my entire time as secretary,” he writes, “was my determination to avoid any new war while we were still engaged in Iraq and Afghanistan.”)

But the reason so few Republican legislators have warmed to the book, as another vector in their assault on Obama, is that Gates unloads on Congress most of all. “Congress,” he writes, “is best viewed from a distance—the farther the better—because up close, it is truly ugly.” He is “outraged” by legislators’ parochialism and their “political bullshit.” He derides the members of the House Foreign Affairs Committee, in particular, as “rude, nasty and stupid.” Throughout his tenure, he would prepare for congressional hearings not by rehearsing polite responses to anticipated questions, but rather by answering “the way I really wanted to, barking and cursing and getting the anger and frustration out of my system, so that my public testimony could be dispassionate and respectful.”

How many ex-officials, upon reading these passages, will gnash their teeth with envy that they hadn’t, or couldn’t, muster the moxie in their memoirs to let it all out the way Gates did? (The reason most of them can’t is that they’re still in the Washington game as lobbyists, consultants, or officials-in-exile, planning their returns.)

What about the lead item in most press summaries of the book: Gates’ critique of Obama? First, it’s not so clear-cut. For the most part, he comes to praise Obama, not to bury him. He calls him “quite pragmatic on national security” (the highest praise from a realpolitik man like Gates) and “the most deliberative president I worked for” (he’s worked for eight), likening his problem-solving methods to Lincoln’s. Of the raid on Bin Laden’s lair (which Gates initially opposed), he writes, “I was so proud to work for a president who had made one of the most courageous decisions I had ever witnessed at the White House.”

On the other hand, he writes, Obama’s White House “was by far the most centralized and controlling in national security of any I had seen since Richard Nixon and Henry Kissinger ruled the roost.” The NSC staff was dominated by young congressional and campaign staffers who had little or no experience in foreign policy. These are familiar criticisms, filed by many.

Gates’ deeper problem with Obama personally is that he was “deeply suspicious” of the military, convinced that his top military advisers—especially Gen. David Petraeus, Gen. Stan McChrystal, and Adm. Mike Mullen—were trying to “box” him in on putting more troops in Afghanistan. Sitting at one contentious White House meeting, Gates suddenly has this revelation: “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.”

The odd thing is that, throughout the book, Gates agrees with all these points—or at least concedes that Obama and his staff had good reason to be suspicious of the generals. He says it right on Page 476: “We at Defense certainly at times contributed to White House suspicions.” The generals were trying to box Obama into higher force levels in Afghanistan than he wanted. Gates writes that, even after Obama agreed on a troop hike very close to the generals’ proposal, it was a “big job” for him—the wartime secretary of defense—to clamp down on their natural urge for more and thus “avoid having the president wake up one morning and discover there were 130,000 troops in Afghanistan rather than the 100,000 he had approved.”

As for Karzai, Gates couldn’t stand him either. And as for the war strategy, Gates notes that Obama’s doubts were affirmed by the two top U.S. intelligence officials at the time, Leon Panetta and James Clapper, for whom Gates otherwise has only good words. “To my chagrin,” he writes, “both … said that another year or two of effort would not lead to a satisfactory outcome.”

Gates never considers the possibility that he might have simply been wrong. At the meeting where Panetta and Clapper expressed pessimism, Gates recalls saying that “the critics were too focused on Karzai and the central government.” But in fact, counterinsurgency—the strategy that Petraeus had laid down and Gates, despite early doubts, embraced—depends crucially on a central government that the local people consider legitimate. The top-to-bottom corruption of Karzai’s regime torpedoed that possibility and thus all but doomed the strategy’s prospects. Gates ridicules Vice President Joe Biden and some of the young NSC staffers for challenging the wisdom of the generals on this point. But in retrospect it looks like Biden and the boys were right.

Gates blames Biden for “poisoning the well” and egging Obama on to wind down the war more quickly. But the fact is, as Gates also acknowledges, Obama sided with him, and against Biden, in almost every clash. Gates further states that Obama made “the right decision” when he announced, at the same time, a surge of 33,000 extra troops and the start of a withdrawal 18 months hence. Gates lashes out at the White House staff for politicizing everything, but he admits that “time and again,” he saw Obama “make a decision that was opposed by his political advisers” or “would be unpopular with his fellow Democrats and supportive interest groups.”

The decisive blow to his relations with Obama occurred in April 2011, just three months before Gates would step down (a decision he’d announced earlier). The two had previously agreed that Gates would restructure the defense budget but that its size wouldn’t change. Now, in the wake of the midterm elections and fiscal pressures across the board, Obama’s chief of staff, Bill Daley, informed Gates that he’d have to cut the budget after all, by another $400 billion over the next 10 years.

“I was furious,” Gates writes. “I pointed my finger at Daley and said, ‘This White House’s word means nothing!’ ” And yet, Gates must know, it’s the president’s job to set national priorities, and political changes unavoidably alter those settings; it’s the defense secretary’s job to devise the best strategy given his limited resources.

Toward the end of the book, Gates writes that he liked almost everyone he worked with in the Obama administration and that everyone there treated him better than he’d ever been treated before. And so, he asks, “Why did I feel I was constantly at war with everybody?” He answers: “It was because … getting anything of consequence done was so damnably difficult.”

I don’t buy it. Gates was such a remarkable secretary of defense precisely because he did get so much done. In the first year of Obama’s presidency, he produced a budget that killed or drastically cut 33 major weapons programs, including the Air Force’s much-cherished Cold War chestnut, the F-22 stealth fighter plane—and he persuaded Congress to go along with all of them. The feat, he rightly boasts, was “unprecedented.” He transformed a business-as-usual Pentagon bureaucracy—seemingly oblivious to the fact that the country was fighting two wars—into a (somewhat) responsive, accountable outfit. He upended the Army’s promotion board and thus allowed some of the most creative colonels, whose careers had been thwarted, to advance to the rank of general.

He also went to bat for the troops. Some readers might roll their eyes at Gates’ many recitations of his love for the troops, of how teary he gets when he visits them in hospitals or writes condolence letters to the relatives of those killed. But these emotions are genuine. He singlehandedly shoved $16 billion in a supplemental budget so that several thousand heavily armored MRAP troop-carriers could be built and sent quickly to Iraq and Afghanistan, against the objections of all the service chiefs—and, as a result, several thousand soldiers’ and Marines’ lives were saved.* When he read of the horrors at Walter Reed hospital, he fired the secretary of the army and cleaned up the mess at once. He also fired the Air Force chief of staff, a four-star general, for slowing down production and delivery of reconnaissance drones, which in Iraq helped the troops spot roadside bombs and track down the insurgents who planted them.

On broader matters, he almost singlehandedly kept President Bush from bombing Iran and, in a series of maneuvers, helped accelerate the isolation of Dick Cheney.

Gates’ descriptions of how he accomplished these feats—the mix of cooptation and coercion that he employed—should be read by every future defense secretary, and executives of all stripes, as a guide for how to command and overhaul a large institution.

Contrary to his harrumphing about the inability to get things done, Robert Gates was probably the single most influential cabinet officer in both the Bush and Obama administrations. But then, in the final few months with Obama, he lost two battles—one over the defense budget, the other over whether to commit military forces to the revolt in Libya (he was opposed). As he puts it, “I had had a tough but—I thought—successful run for four years. The last six months were turning out very differently.” He’d grown accustomed to winning his political wars, and I suspect the shock of losing a couple of battles colored—and embittered—his memory of all the earlier conflicts and tensions, even those where he’d emerged victorious.

He started writing this memoir very soon after leaving office, perhaps too soon for the sensation to wear off. At times, one can’t help but wonder if he recognizes the full depths of his bitterness. Take Pages 392–93, where, after describing in some detail an NSC meeting on what to do if Israel attacked Iran, Gates writes:

I was put off by the way the president closed the meeting. To his closest advisers, he said, “For the record, and for those of you writing your memoirs, I am not making any decision about Israel or Iran. Joe, you be my witness.” I was offended by his suspicion that any of us would ever write about such sensitive matters.

Yet here he is, doing just that. Maybe he should have waited a year or so to gather his thoughts, if not for propriety (as some critics have suggested) then at least to gain some perspective.

Still, for all its quirks, this is a compelling memoir and a serious history. Gates’ chapters on his dealings with foreign leaders are particularly interesting, especially his accounts of Dimitri Medvedev (promising as long as he lasted), Vladimir Putin (a duplicitous return of the czars), and Benjamin Netanyahu (whom he doesn’t trust in the slightest and whose outsize influence in U.S. politics he laments). He also paints the most detailed picture we’ve seen yet of the internal debates over what to do about the Arab uprisings.

Gates writes at one point that Obama entered the White House with the worst cards that any president in modern times had been dealt. He writes several times that America’s—any one nation’s—ability to control events is severely limited. His memoir, more than anything, is the story of how he and two presidents grappled with those facts.

Correction, Jan. 14, 2014: This article previously misstated the number of MRAP troop-carriers Gates enabled the budgeting for. It was several thousand, not several hundred. (Return.)