Robert Gates stepped down as Secretary of Defense on July 1, 2011, after four and a half widely praised years serving two presidents of opposing parties. As he tells it in a new memoir that is refreshingly and uncommonly blunt about his relations with the White House and Congress, he was, "in personal terms, treated better by the White House, Congress and the press for longer than almost anyone I could remember in a senior U.S. government job."

Yet while still running the Pentagon he emailed a friend: "People have no idea how much I detest this job."

Few men have had better preparation for leading the Defense Department. Before taking that post, Mr. Gates served as director of the Central Intelligence Agency and Deputy National Security Advisor in a long and distinguished government career.

What drove him up the wall, he wrote, was Washington's "dysfunction" and, in particular, the way parochial politics invaded every sphere of decision-making. While not leaving out Congress, which he said treated administration witnesses with contempt, it appears that his largest problem was with the White House under President Barack Obama. President George W. Bush, he said, seldom if ever discussed domestic politics with him.

He wrote: "With Obama, however, I joined a new, inexperienced president determined to change course - and equally determined from day one to win re-election."

The result was the president's "determination that the White House tightly control every aspect of national security policy and even operations. His 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."

President Obama gave his chiefs of staff, Rahm Emanuel and Bill Daley, "as well as such core political advisers as Valerie Jarrett, David Axelrod and Robert Gibbs" roles in national security decisions "that I had not previously experienced."

Mr. Gates wrote that White House aides attempted to bypass him to communicate directly with senior military commanders. When Vice President Joe Biden and National Security Advisor Tom Donilon tried to give him orders, he sent them packing by saying they were not in the chain of command.

Mr. Gates also reported that White House staff and the vice president constantly told the president that his Afghanistan policy was not working, often putting the blame on commanders in the field. This tended to poison working relations between the White House and the military.

For example, Secretary Gates and the military agreed with the president's 2009 decision for a limited surge in Afghanistan, but preferred to condition the time and pace of a future drawdown of forces on facts on the ground.

When Gen. David Petraeus made public remarks in 2011 critical of a rigid exit timetable in Afghanistan, President Obama hit the ceiling, suggesting that he was being "gamed" by the Pentagon. Wrote Mr. Gates, "As I sat there, I thought: the president doesn't trust his commander, can't stand [Afghanistan President Hamid] 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."

With such revealing perspectives (including a dismissive appraisal of Mr. Biden), it is clear the Mr. Gates has closed the door to Washington behind him. What a deeper reading of his memoir reveals is the way that Washington's hyper-political environment burns out the best of the nation's servants and makes public service an agony for those who are driven by more than partisan calculations.