Kabul, Afghanistan (CNN) -- Afghan rage over the burning of Qurans by NATO troops continued Thursday even after a President Barack Obama apologized for the "error."
Afghanistan erupted in violent demonstrations after the troops burned the Islamic religious material at the beginning of the week.
Two American troops were killed Thursday by a man wearing an Afghan National Army uniform, a U.S. official said, asking not to be named discussing casualties. The gunman is thought to have been acting in conjunction with a protest outside the base, the official said.
In a letter delivered to Afghan President Hamid Karzai, Obama called the act "inadvertent," Karzai's office and National Security Council spokesman Tommy Vietor said Thursday.
"We will take the appropriate steps to avoid any recurrence, including holding accountable those responsible," Obama said in the letter delivered by Ryan Crocker, the U.S. ambassador to Afghanistan.
Karzai said that he had appointed a team composed of Muslim legal scholars from the Ulemma Council and Ministry of Haj to travel to Bagram and investigate.
Obama's apology brought this rejoinder from GOP presidential candidate Newt Gingrich: "The president apologized for the burning, but I haven't seen the president demand that the government of Afghanistan apologize for the killing of two young Americans."
The protest and shootings came as the Taliban called on Muslims to attack NATO military bases and convoys and to kill soldiers following the admission that NATO troops had incinerated the books at Bagram Airfield.
Afghan officials investigating urged Afghans to "exercise self-restraint" and "avoid resorting to protests and demonstrations that may provide ground for the enemy to take advantage of the situation."
The investigators called the burning "insulting and shameful," saying NATO officials had promised to bring the "perpetrators of the crime ... to justice as soon as possible."
"As the situation is still under investigation, it would be premature to speculate on any potential outcomes," said NATO International Security Assistance Force spokesman Lt. Col. Jimmie Cummings. "Any disciplinary action, if deemed warranted, will be taken by U.S. authorities after a thorough review of the facts pursuant to all law and regulation and in accordance with due process."
Muslims believe the Quran is the word of God, so holy that people should wash their hands before even touching the sacred book. Desecrating the Quran is seen as an act of intolerance and bigotry.
At least two demonstrators also were killed in the exchange of gunfire near the base where the two Americans died, said Haji Mohammad Hassan, chief of Khugyani district in eastern Nangarhar province.
Two U.S. soldiers and seven demonstrators were injured in the clash, too, he said.
"We don't know who started the shooting first and what kind of guns were used, but we have started our investigation to find out the details of the incident," Hassan told CNN.
Another demonstration occurred near a Norwegian-run Provincial Reconstruction Team compound in Maimana, the provincial capital of Faryab province, a regional police spokesman said.
Afghan security forces prevented the 700 to 800 demonstrators from entering the compound, said police spokesman Lal Mohammad Ahmadzai said. They burned a few civilian vehicles parked near the compound, he added.
American diplomats in Kabul and the north and south of Afghanistan were on lockdown for a second day in the face of protests, U.S. Embassy spokesman Mark Thornburg said.
At least five people were killed Wednesday in demonstrations.
The commander of NATO's ISAF, Gen. John Allen, apologized Tuesday. The materials had been gathered for disposal and were inadvertently given to troops for burning, Allen said.
"It was not a decision that was made with respect to the faith of Islam," he said. "It was a mistake. It was an error. The moment we found out about it, we immediately stopped and we intervened."
The Taliban on Thursday rejected the apology.
In an e-mail, the Islamist militia accused "the invading infidel authorities" of trying to calm the situation with two "so-called show(s) of apologies, but in reality they let their inhuman soldiers insult our holy book."
They called on Afghans to take revenge "until the doers of such inhumane actions are prosecuted and punished."
"We should attack their military bases, their military convoys, we should kill their soldiers, arrest their invading soldiers, beat them up and give a kind of lesson to them that they never dare to insult the holy Quran," the message said.
Afghan religious scholar Anayatullah Baligh said it can be appropriate to burn a damaged Quran to dispose of it, but that it should be done by a Muslim performing the act respectfully.
"I can't tell you whether Americans intentionally burned the copies of the holy Quran to make Muslims angry or if they did it mistakenly," he said, but said their "carelessness" was "a crime they have committed against the holiest book of 2 billion Muslims around the world."
A military official told CNN on Thursday that it was unclear how many Qurans were involved and that some had been partially burned.
The inability of most American troops at the base to read the texts could have contributed to the mistake, the official said, asking not to be named discussing an ongoing investigation.
A second military official said the materials had been removed from a detainee center's library because they contained "extremist inscriptions" and there was "an appearance that these documents were being used to facilitate extremist communications."
U.S. apologies have not appeased Afghans, who massed outside the Bagram base Tuesday, chanting "Death to America! Death to the Afghan government! Long live Islam!"
Protesters burned tires and threw rocks Wednesday outside Camp Phoenix near Kabul International Airport, the U.S. Embassy said in its official Twitter feed.
In Jalalabad, hundreds chanted "Down With America."
Authorities have questioned some troops as part of their investigation, but no one has been detained, a coalition official said.
Last year, when Florida pastor Terry Jones presided over what he called a trial of the Quran and burned a copy, Afghans took to the streets. In the northern Afghan city of Mazar-e Sharif, demonstrators stormed a U.N. office and killed 12 people. In Kandahar, three people were killed, and nine in another when police clashed with stone-throwing demonstrators.
U.S. officials condemned the pastor's act.
CNN's Lesa Jansenand Chris Lawrence in Washington contributed to this report.