(Adds more comments from Obama and Gates, background)
WASHINGTON, Jan 13 (Reuters) - President Barack Obama on Monday rejected criticism from former Defense Secretary Robert Gates, who questioned whether the president supported his own policy toward Afghanistan.
Answering questions during an Oval Office appearance, Obama said Gates was an outstanding defense secretary and that because of the strategy that the Obama administration formulated, the United States will have concluded combat operations in Afghanistan by the end of this year.
"I think what's important is that we got the policy right but that this is hard and it always has been," Obama said.
Gates, who was defense secretary from 2006 to 2010, wrote a memoir released this week entitled "Duty" that complains that Obama did not believe in his own strategy and "doesn't consider the war to be his."
"Just as I have continued to have faith in our mission, most importantly I've had unwavering confidence in our troops, in their performance in some of the most difficult situations," Obama said.
He said the United States and its coalition partners still have troops in harm's way and "we need to see this job all the way through."
After Obama was elected in 2008 to succeed Republican President George W. Bush, Gates agreed to Obama's request that he remain as defense secretary, becoming the first Pentagon chief to serve presidents of different parties.
Obama has made no secret of wanting to extract U.S. troops from Afghanistan.
His administration is currently locked in a test of wills with Afghanistan President Hamid Karzai. If a contingent of U.S. troops is to remain in Afghanistan after the final pullout at the end of this year, then the Afghan government must sign a bilateral security agreement.
Afghanistan has so far refused to do so, leaving White House officials to warn that all U.S. troops will pull out at the end of the year with no deal.
Gates, in interviews, has sought to temper some of his criticism of the president in his book.
"The truth is we had a very good personal relationship," Gates told National Public Radio. "We discussed our differences openly. He was always civil and kind to me, gave me a lot of trust and confidence." (Reporting by Steve Holland; Editing by James Dalgleish and Dan Grebler)