The former defense secretary who served under both President Barack Obama and President George W. Bush has less than glowing praise for America’s top two elected officials.

In a new memoir, “Duty: Memoirs of a Secretary at War,” former Pentagon chief Robert Gates writes that Obama lacked commitment to the decisions he made about his strategy in Afghanistan, the New York Times reported Tuesday.

“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,” Gates writes in the new book. “For him, it’s all about getting out.”

In a statement, National Security Council spokesperson Caitlin Hayden said the president "deeply appreciates" Gates' service and that Obama "welcomes differences of view among his national security team, which broaden his options and enhance our policies."

"Deliberations over our policy on Afghanistan have been widely reported on over the years, and it is well known that the President has been committed to achieving the mission of disrupting, dismantling and defeating al Qaeda, while also ensuring that we have a clear plan for winding down the war, which will end this year," Hayden added.

In an excerpt published in the Wall Street Journal, Gates wrote that Obama insisted 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," he wrote.

Jim Watson / Reuters, file Then-Defense Secretary Robert Gates, right, and Vice President Joe Biden attend the United States Forces-Iraq change of command ceremony in Baghdad on Sept. 1, 2010.

Gates' words for Vice President Joe Biden are even more harsh, the Times reported.

“I think he has been wrong on nearly every major foreign policy and national security issue over the past four decades,” Gates wrote of Biden, whom he also described as a “man of integrity.”

Hayden said Obama "disagrees with Secretary Gates' assessment" of his vice president.

"From his leadership on the Balkans in the Senate, to his efforts to end the war in Iraq, Joe Biden has been one of the leading statesmen of his time, and has helped advance America's leadership in the world. President Obama relies on his good counsel every day," Hayden said.

Before becoming vice president, Biden served as the longtime head of the Senate Foreign Relations Committee.

While critical of Biden, Gates appears to favor former Secretary of State Hillary Clinton. The NYT writes that Gates has “especially high praise” for Clinton.

The Washington Post adds, however, that Gates says both Clinton and Obama admitted to basing their opposition to the 2007 "surge" in Iraq in part on political considerations.

"Hillary told the president that her opposition to the [2007] surge in Iraq had been political because she was facing him in the Iowa primary. . . . The president conceded vaguely that opposition to the Iraq surge had been political. To hear the two of them making these admissions, and in front of me, was as surprising as it was dismaying," Gates writes, according to the Post.

Both Clinton and Biden are considered possible contenders for the 2016 Democratic presidential nomination.

NBC's Peter Alexander and Shawna Thomas contributed to this report.