President Obama rejects criticism from former Defense Secretary Robert Gates over his handling of the war in Afghanistan. (Reuters)

President Obama on Monday, in his first response to a new tell-all book by former defense secretary Robert Gates, praised Gates’s “outstanding” service and defended his administration’s approach to Afghanistan, saying that “war is never easy.”

In his book, "Duty: Memoirs of a Secretary at War,” Gates claims that Obama never fully embraced his strategy of sending more troops to Afghanistan. The book also offers wide-ranging criticism of how the White House carried out foreign policy in the first two years of the Obama administration.

"What's important is that we got the policy right, but that this is hard, and it always has been,” the president said on Monday in response to a question from the media at a meeting with the Spanish prime minister. “Whenever you've got men and women that you're sending into harm's way, after having already made enormous investments of blood and treasure in another country, then part of your job as commander in chief is to sweat the details on it."

Obama also said that “Secretary Gates was an outstanding secretary of defense, a good friend of mine, and I'll always be grateful for his service."

Earlier Monday, Gates sought to clarify comments he made in his book that suggested that, as a presidential candidate in 2007, Obama opposed troop surge in Iraq for political purposes.

"What I say in the book was that the president conceded a lot of opposition to the surge had been political," Gates said on NBC's "Today Show." "He never said that his opposition had been political. And, in fact, his opposition was consistent with his opposition to the war all along."

In the book, Gates says clearly that then-secretary of state Hillary Clinton admitted her opposition to the surge had been because of her 2008 primary against Obama.

Gates then wrote that, "The president conceded vaguely that opposition to the Iraq surge had been political" — not a direct claim about the president.

But Gates then wrote that he regarded both Clinton and Obama's concessions as disappointing: "To hear the two of them making these admissions, and in front of me, was as surprising as it was dismaying.”

Appearing on National Public Radio, Gates also expounded on his claim that Vice President Biden has routinely been wrong about almost every major national security and foreign policy decision of the last four decades.

Gates wasn't backing off that contention.

“Well, two things. First of all, I think it’s fair to say that, particularly on Afghanistan, the vice president — he and I were on opposite sides of the fence on this issue," Gates said. "And he was in there advising the president every day. He was, I think, stoking the president’s suspicion of the military. But the other side of it is, frankly, I believe it.”