An Afghan soldier shot dead two American soldiers , as the Taliban called for attacks on military bases and convoys in retaliation for the burning of copies of the Qur'an.

As a third day of violence raged across Afghanistan in retaliation for the desecration by US soldiers, Barack Obama sent a letter of apology to the president, Hamid Karzai. "President Obama has written that the incident in their facility was not intentional, and assured the president of full co-operation," the statement said.

Obama expressed his administration's "regret and apologies over the incident in which religious materials were unintentionally mishandled", said White House national security council spokesman Tommy Vietor.

The violence began when Afghan workers at the Bagram airbase discovered copies of the Qur'an among a pile of waste paper sent for incineration late on Monday evening, and pulled them from the flames. Karzai told MPs that a US soldier had acted "out of ignorance and with poor understanding" of the Koran's importance as Islam's holy book, a presidential statement said.

Thousands of Afghans took to the streets the next day, and their numbers have grown as news of the burning spread across the country. Embassies, the United Nations and other foreign organisations have restricted travel and kept their staff inside fortified compounds to protect them from possible violence.

Today demonstrators burned cars outside a Norwegian base in the north and attacked a French compound in eastern Kapisa province. In Kabul there were some injuries but no deaths, as a heavy police presence contained riots. Elsewhere security forces struggled to cope, and the US embassy extended a travel ban to parts of northern Afghanistan.

The Afghan National Army soldier who turned his gun on US troops appeared to have been stationed on a joint base, inside the security cordon that protected other foreign troops from the enraged crowds.

"More than 1,000 people were protesting today in Khogyani district, and they marched towards Kaja where there is a US base," said Haji Mohammad Hassan, district governor for Khogyani.

"In part of the US headquarters a soldier opened fire on the Americans, and after that ran away to hide himself among the protesters, and is still with them."

Two civilians were also killed when someone opened fire near the base, Hassan added, but he could not confirm the source of the shots.

Although anger has been directed at foreign troops and foreign governments, most of the 11 people killed and dozens injured have been Afghans. A call for calm from Karzai late on Wednesday night did little to quell the rage. There are fears of further violence on Friday if imams take up the issue in their sermons. A report on the incident by senior clerics and Nato officials is expected to reach Karzai by the end of the week.

Obama's was the latest in a string of rapid but apparently ineffectual efforts by top US civilian and military officials to contain the damage, which is expected to complicate efforts by Kabul and Washington to seal a strategic deal to keep some US troops in the country past 2014.

The US and Nato commander in Afghanistan, General John Allen, rushed to deliver a fervent apology to the "noble people of Afghanistan" within hours of the burning. The US defence secretary, Leon Panetta, also apologised for the "inappropriate treatment" of copies of the Qur'an.

In April 2011, when news that a US pastor in Florida had burned a Qur'an reached Afghanistan, seven foreign UN workers and at least 13 Afghans were killed in protests that raged for several days.