"What's important is we got the policy right, but this is hard and it always has been," Obama told reporters on Monday at the White House, rejecting criticism from former Pentagon chief Robert Gates.
Gates, who was defence secretary from 2006 to 2011, questioned in a new memoir whether Obama supported his own policy in Afghanistan.
"Just as I have continued to have faith in our mission, more importantly I have had unwavering confidence in our troops," Obama said.
The failure of the Afghan government to sign a bilateral security agreement with the US has strained ties between the two countries.
Obama: I have had unwavering confidence in our troops
The White House has urged Afghan President Hamid Karzai to sign the agreement by the end of 2013 to give enough time for planning and deciding the number of troops to remain in Afghanistan after 2014.
However, Karzai refused to sign the accord until after a new president is elected on April 5, 2014, or unless Washington meets preconditions including immediately halting US raids on Afghan residences, ensuring viable security and supporting meaningful peace talks with the Taliban.