The increasingly deadly conflict in Afghanistan is a "serious fight" but one essential for the future stability of the country, the US president says, BBC reported.
Insisting that US and allied troops have pushed back the Taliban, Barack Obama said the immediate target was to steer Afghanistan through elections.
The country is due to hold a presidential vote in August.
Mr Obama spoke to Sky News as concern grew in the UK at the rising British death toll in Afghanistan.
UK Prime Minister Gordon Brown was also forced on Saturday to justify British involvement in Afghanistan.
Mr Brown said the UK's military deployment there was aimed at preventing terrorism in the UK.
Fifteen British troops have died in the past 10 days, pushing the country's number of deaths in Afghanistan past the number killed in action in Iraq.
Speaking during a day-long visit to Africa, Mr Obama also told Sky News that the battle in Afghanistan was a vital element in the battle against terrorism.
He said the continued involvement of British troops in the conflict was necessary, right and was a vital contribution to UK national security.
"This is not an American mission," Mr Obama said.
"The mission in Afghanistan is one that the Europeans have as much if not more of a stake in than we do.
"The likelihood of a terrorist attack in London is at least as high, if not higher, than it is in the United States."
He praised the efforts of all troops currently fighting the Taleban in gruelling summer heat, singling out British forces for praise when asked if their role was still important.
"Great Britain has played an extraordinary role in this coalition, understanding that we can not allow either Afghanistan or Pakistan to be a safe haven for al-Qaeda, those who with impunity blow up train stations in London or buildings in New York.
"We knew that this summer was going to be tough fighting. They [the Taliban] have, I think, been pushed back but we still have a long way to go. We've got to get through elections."
Since taking office in Washington in January of this year, Mr Obama has announced a troop "surge" in Afghanistan.
The US has said it is sending up to 30,000 new troops to Afghanistan this year to take on a resurgent Taleban. They will join 33,000 US and 32,000 other Nato troops already in the country.
He also replaced the incumbent US commander in the country, ousting Gen David McKiernan less than a year into his command.
The new US chief in Afghanistan, Gen Stanley McChrystal, has a stellar reputation from his days commanding special forces operations in Iraq.
He has been tasked with the mission of outsmarting the Taliban, who continue to win support among ordinary Afghans often caught in the crossfire of the bitter fighting.
High numbers of Afghan civilian casualties have become an issue of major concern to the US. Afghan President Hamid Karzai has regularly called on the international forces to reduce the numbers of Afghans killed in its operations.
Speaking to Sky News, Mr Obama said although forces were currently engaged in heavy fighting, new strategies for building bridges with Afghan society would be considered once the country had held its presidential election.
Afghanistan needed its own army, its own police and the ability to control its own security, Mr Obama said - a strategy currently being implemented in Iraq, where security is being handed over to Iraqi forces.
"All of us are going to have to do an evaluation after the Afghan election to see what more we can do," the president said.
"It may not be on the military side, it might be on the development side providing Afghan farmers alternatives to poppy crops, making sure that we are effectively training a judiciary system and a rule of law in Afghanistan that people trust."
"We've got a core mission that we have to accomplish."