Obama, speaking in the White House Rose Garden, announced his decision to wind down the troop level next year and to pull out of all forces except embassy personnel by the end of 2016, ending the longest US war.
But Obama said: "We will only sustain this military presence after 2014 if the Afghan government signs the Bilateral Security Agreement that our two governments have already negotiated."
"This agreement is essential to give our troops the authorities they need to fulfill their mission, while respecting Afghan sovereignty," Obama said.
The United States negotiated the agreement with outgoing President Hamid Karzai, who has since refused to sign it. But Obama noted that both candidates in the June 14 runoff presidential election — Ashraf Ghani and Abdullah Abdullah — said that they would sign the deal.
"So I'm hopeful we can get this done," Obama said.
Obama credited the US war with eliminating militants behind the 9/11 attacks but sounded a note of caution on what the United States could still accomplish.
"We have to recognize Afghanistan will not be a perfect place and it is not America's responsibility to make it one," Obama said.
"The future of Afghanistan must be decided by Afghans. But what the United States can do, what we will do, is secure our interests and help give the Afghans a chance, an opportunity to seek a long overdue and hard-earned peace," he said.