The Afghans' furious response to the Quran burning - three days of riots in several cities nationwide - reflected the anger at what they perceive as foreign forces disrespect for Afghan laws and culture.
In a letter sent to Afghan President Hamid Karzai, Obama expressed his administration's "regret and apologies over the incident in which religious materials were unintentionally mishandled," White House national security council spokesman Tommy Vietor said. He added that the letter was delivered by Ryan Crocker, the US ambassador to Afghanistan, on Thursday afternoon.
Karzai's office said Obama called the Quran burnings "inadvertent," adding that the US "will take the appropriate steps to avoid any recurrence, to include holding accountable those responsible."
US apologies for the desecration - and an appeal from Karzai for calm - have failed to control the anger of Afghans, who staged rallies in seven provinces on Thursday, sparking clashes with Afghan police and security forces that left at least five demonstrators dead. Seven protesters were killed in clashes on Wednesday.
The two NATO service members were killed in eastern Afghanistan by a man dressed in an Afghan army uniform. Both troops were Americans, according to a US official, who confirmed their nationalities on condition of anonymity because he was not authorized to disclose the information.
Mohammad Hassan, an official in Nangarhar province where the shooting took place, said the two Americans were shot by an Afghan soldier after soldiers fired in the air to disperse protesters outside a US base in the Khogyani district. Two protesters were also killed in the ensuing gunfire, Afghan officials said.
A rising number of Afghan security forces, or militants wearing their uniforms, have shot and killed US and NATO service members.
The Taliban on Thursday called on Afghans to attack foreign troops, and their spokesman has issued a statement ordering its commanders to embrace and protect the families of any Afghan policeman or soldier who turns his gun on foreign troops. "Call them heroes," he said.
Protesters also rioted outside a US base in Mehterlam, the capital of Laghman province. Police broke up a demonstration using water cannons and batons after protesters tried to storm the base.
"Hundreds of our people in Laghman province gathered because of the burning of the holy book by the Americans," said protester Mohammad Issa.
"Everyone is so emotional. The burning of the Quran broke our hearts and we are attacking the PRT because they are American," he said, using the acronym for the provincial reconstruction team.
In Oslo, Norwegian military spokesman Ivar Moen said a Norwegian soldier was wounded after demonstrators threw a hand grenade into a military base in Maimanah, in northwestern Faryab province where Norwegian, Latvian, Afghan and US troops are deployed.
The soldier was wounded after about 200 demonstrators hurled rocks at the base and shouted epithets. Norwegian troops responded with warning shots and tear gas. Moen said the demonstration was over, but new protests are expected tomorrow.
In the city of Baghlan in the north, clashes between police and protesters attacking the police headquarters left one person dead. Police said 10 officers were also wounded, two from gunshot wounds.
Police said another two protesters were killed and six wounded in another exchange of gunfire during a protest in southern Uruzgan province.
The riots erupted on Tuesday after Afghan workers at the main American military base, Bagram Air Field, saw soldiers dumping books in a pit where garbage is burned and noticed Qurans and other religious material among the trash.
The top US and NATO commander, General John Allen, quickly issued an apology and telephoned Karzai and major news organizations to explain that a collection of religious materials, including Qurans, had mistakenly been sent to be incinerated. As soon as someone realized what they were burning, they stopped and retrieved what was left, Allen said.
Karzai also met Thursday with parliamentarians - many of whom had called on Wednesday for Afghans to wage a holy war against international forces. He told them that a US officer responsible for the incident "didn't understand" what he was doing and the United States "accepted the mistake of its officer."
He commended the US government for "acting quickly regarding this issue and apologising." Karzai said that he was most concerned with making sure that such acts are not repeated.
Four copies of the Quran were burned before the incineration was halted, according to initial Afghan government reports.
NATO and Afghan investigators on Wednesday visited the Parwan detention facility, where the Qurans were taken from. US officials said they had been removed from the shelves of the facility's library because they contained extremist messages or inscriptions. The White House said it was an accident that they were sent to be burned.