Obama hailed the approaching end of the war and thanked US troops
US President Barack Obama has pledged to "finish the job" and end the Afghan war, addressing the US public live from a military base in Afghanistan.
Speaking a year after Osama Bin Laden's death, he thanked US troops and hailed plans to end combat operations.
Mr Obama arrived in Afghanistan on a surprise visit to sign an agreement on future Afghan-US ties with President Hamid Karzai, ahead of a Nato summit.
Hours after his speech at least six people died in a bomb blast in Kabul.
Afghan officials said at least two suicide bombers targeted a guesthouse popular with foreigners in the eastern part of the Afghan capital.
They said that most of the victims were civilians.
Two security officials later told the BBC that two to three attackers were still holed up in a building near the scene of the original attack. They have been firing from machine guns and firing RPGs.
Police have now surrounded the area.
The Taliban later claimed responsibility for the attacks.
Earlier, Mr Obama said signing the pact with President Karzai was "a historic moment" for both nations.
Hit visit and TV address come as correspondents say public patience with the war in Afghanistan is wearing thin.
In the speech, beamed back to prime-time evening audiences in US, the president said that at the upcoming Nato summit, to be held in Chicago, the alliance would "set a goal for Afghan forces to be in the lead for combat operations across the country next year".
Nato has already committed to withdrawing from combat operations in Afghanistan by the end of 2014.
"I will not keep Americans in harm's way a single day longer than is absolutely required for our national security," Mr Obama said. "But we must finish the job we started in Afghanistan, and end this war responsibly."
Correspondents say Mr Obama's words appear to be aimed at showing American voters he is pursuing a strategy to wind down the war, while reassuring Afghans in the face of a continuing Taliban insurgency.
'Path to peace'
About 23,000 of the 88,000 US troops currently in the country are expected to leave Afghanistan by the summer, with all US and Nato troops out by the end of 2014.
"It is time to renew America," Mr Obama said towards the end of his remarks.
"My fellow Americans, we have travelled through more than a decade under the dark cloud of war. Yet here, in the pre-dawn darkness of Afghanistan, we can see the light of a new day on the horizon," Mr Obama said.
"The Iraq war is over. The number of our troops in harm's way has been cut in half, and more will be coming home soon. We have a clear path to fulfil our mission in Afghanistan, while delivering justice to al-Qaeda."
During the speech, Mr Obama outlined the agreement he had just signed with Afghan President Hamid Karzai.
The BBC's Paul Adams says 20 months of negotiation finally produced an agreement after differences over night raids by special forces and the handling of prisoners were ironed out.
According to the US president, the document outlines plans for training Afghan forces and supporting counter terrorism efforts, as well as "Afghan commitments to transparency and accountability".
Mr Obama also spoke of a "negotiated peace" with the Taliban, saying that if insurgents break with al-Qaeda, and follow the "path to peace", there can be reconciliation.
He said that ahead of the Chicago meeting of Nato, he had made it clear to Pakistan that it could be an "equal partner in the process".
Pakistan and US relations soured after Mr Obama launched the raid that killed bin Laden inside the country's border.
"In pursuit of a durable peace, America has no designs beyond an end to al-Qaeda safe-havens, and respect for Afghan sovereignty."
Mr Obama also rejected calls to leave Afghanistan before the 2014 Nato timeline, saying "we must finish the job we started in Afghanistan, and end this war responsibly".
In the wake of the agreement, the US is to designate Afghanistan as a major non-Nato ally, US officials are quoted as saying by Reuters news agency.