U.S. President Barack Obama is congratulating the people of Afghanistan on completing their presidential election, in the face of violent extremism. Mr. Obama spoke before leaving for a weekend trip to the presidential retreat at Camp David.

President Obama called the election an "important step forward" for the Afghan people, after decades of violence and instability.

Mr. Obama says the United States knew the Taliban would try to derail the vote, but failed.

"Yet even in the face of this brutality, millions of Afghans exercised the right to choose their leaders and determine their own destiny. And as I watched the election I was struck by their courage in the face of intimidation and their dignity in the face of disorder," he said.

The campaigns of Afghan President Hamid Karzai and his challenger, former Foreign Minister Abdullah Abdullah, are both claiming victory. The country's Independent Election Commission says it is too early to say who won.

Mr. Obama says the United States will await the results with the rest of the world, and will work with whichever candidate wins.

"Our only interest was the result fairly, accurately reflecting the will of the Afghan people," he said.

The president says the United States will continue working with its Afghan partners to strengthen security and governance, defeat al-Qaida, and bring U.S. troops home.

"Our goal is clear: to disrupt, dismantle and defeat al-Qaida and their extremist allies. That goal will be achieved, and our troops will be able to come home, as Afghans continue to strengthen their own capacity and take responsibility for their own future," the president said.

As he was leaving Friday, Mr. Obama was asked to comment on the hero's welcome given Thursday to freed Lockerbie bomber Abdel Basset al-Megrahi as he returned home to Libya. The president called it "highly objectionable."