WASHINGTON  - President Barack Obama on Tuesday said the United States was committed to long-term ties with Afghanistan but did not want to keep troops there longer than needed to disable al Qaeda and ensure a modicum of stability as foreign forces withdraw.

“President (Hamid) Karzai understands we are interested in a strategic partnership with the Afghan people and the Afghan government,” Obama told reporters in a news conference.

“We are not interested in staying there any longer than is necessary to ensure that al Qaeda is not operating there and that there is sufficient stability that it doesn’t end up being a free-for-all after Isaf has left,” he said, referring to the Nato military force led by the United States. Obama spoke as the White House seeks to put behind it the spasm of violence that erupted when US soldiers burned copies of the Quran at a Nato military base last month - and the questions it has raised about US strategy. The outcry over the desecration of the Muslim holy book, which included a spate of so-called insider attacks against US soldiers, has underscored the challenges that remain in Afghanistan despite Western nations’ plans to withdraw most of their troops by the end of 2014. “Yes, the situation with the Quran burning concerns me,” Obama said. “I think that it is an indication of the challenges in that environment and it’s an indication that now is the time for us to transition.”

Nato forces have begun to gradually put local police and soldiers in the lead for security. While the Afghan military is far larger and better equipped than it was, it will remain heavily reliant on outside help and funding for years to come.

Obama said he was confident his plan could be carried out. “But it’s not going to be a smooth path,” he said. “There are going to be bumps along the road just as there were in Iraq.”

More than a decade after the Taliban government was toppled, the Afghan insurgency remains a potent threat. US ties with the Afghan government are strained as the two sides struggle for an agreement that would define the long-term US presence in Afghanistan.

On Tuesday, Karzai’s government said it may soon reach an agreement with the Obama administration on US-managed detention centres, one of several sticking points that have held up conclusion of the agreement for months.

The White House has been hoping to wrap up the agreement before Nato leaders gather in Chicago in May. The United States now has around 90,000 soldiers in Afghanistan.

Afghanistan surely will take a backseat to issues related to the US economy in presidential elections in November, when Obama is hoping to clinch a second term. The president is likely to highlight his successes in foreign policy, especially the secret raid that killed al Qaeda leader Osama bin Laden in Pakistan last May.

On Monday, a poll showed that more than half of Americans supported Obama’s decision to apologise to Karzai for the Quran burnings.