KABUL, Afghanistan (AP) -- A gunman killed two American military advisers with shots to the back of the head Saturday inside a heavily guarded ministry building, and NATO ordered military workers out of Afghan ministries as protests raged for a fifth day over the burning of Qurans at a U.S. army base.
The Taliban claimed responsibility for the attack at the Interior Ministry, saying it was retaliation for the Quran burnings, after the two U.S. servicemen -- a lieutenant and colonel and a major -- were found dead on their office floor, Afghan and western officials said.
The top commander of U.S. and NATO forces recalled all international military personnel from the ministries, an unprecedented action in the decade-long war, highlights growing friction between Afghans and their foreign partners at a critical juncture in the war.
The U.S.-led coalition is trying to mentor and strengthen Afghan security forces so they can lead the fight against the Taliban and foreign troops can go home. That mission, however, requires a measure of trust at a time when anti-Western sentiment it at an all-time high.
Afghan Defense Minister Gen. Abdul Rahim Wardak called U.S. Defense Secretary Leon Panetta to apologize for the shooting and offer his condolences, Pentagon press secretary George Little said in a statement released in Washington.
"This act is unacceptable and the United States condemns it in the strongest possible terms," Little said.
Security is tight in the capital, which is covered in snow, and foreigners working at the U.S. Embassy and other international organizations have been banned from leaving their compounds.
U.S. officials said they were searching for the assailant, who has not been identified by name or nationality.
The two American service members were found by another foreigner who went into the room, which is only accessible by people who know the correct numerical combination, according to the Afghan official, who spoke to The Associated Press on condition of anonymity because he was not authorized to disclose details about the shootings.
They were shot in the back of the head, according to Western officials, who spoke on condition of anonymity because they were not authorized to disclose the information. Authorities were poring over security camera video for clues, the Afghan official said.
Taliban spokesman Zabiullah Mujahid identified the shooter as one of their sympathizers, Abdul Rahman. He said an accomplice inside the ministry helped Rahman get inside the compound to kill the Americans to retaliate for the Quran burnings.
"After the attack, Rahman informed us by telephone that he was able to kill four high-ranking American advisers," Mujahid said. The Taliban often inflate death tolls and sometimes claim responsibility for killings they did not conduct
Little, of the Pentagon, said Wardak indicated that President Hamid Karzai was assembling religious leaders and other senior Afghan officials to take urgent steps to protect coalition forces.
U.S. Gen. John Allen, the top commander of U.S. and NATO forces in Afghanistan, met with Afghan Interior Minister Bismullah Khan Mohammadi, who offered both his condolences to the families of the victims and his apologies, Little said.
Afghanistan's interior and defense ministers were expected in Washington next week
Allen said he recalled all NATO personnel from the ministries "for obvious force protection reasons" but also said the alliance remains committed to its partnership with the Afghan government. NATO forces have advisers embedded in many Afghan ministries. The advisers are helping to develop the ministries so that Afghans can take the lead by the end of 2014, when foreign combat forces are to transfer control of security to Afghan security forces.
At least 28 people have been killed and hundreds wounded since Tuesday, when it first emerged that Qurans and other religious materials had been thrown into a fire pit used to burn garbage at Bagram Air Field, a large U.S. base north of Kabul.
President Barack Obama and other U.S. officials have apologized for what they said was a mistake, but their regrets have not quelled the deadly protests.
An Afghan soldier turned his gun on foreign troops, killing two American soldiers, during one riot outside a U.S. base in Nangarhar province on Thursday. It was the latest in a rising number of incidents where Afghan soldiers or policemen, or gunmen wearing their uniforms, have killed NATO forces. Last month, France suspended its training program and threatened to withdraw its forces from Afghanistan a year ahead of schedule after an Afghan soldier shot and killed four French soldiers on a base in the east.
Karzai has said that the Afghan people have a right to protest the Quran burnings, but he urged them to demonstrate peacefully and refrain from destroying property. In a statement on Saturday, Karzai urged Afghan security forces to be patient with the protesters.
Hundreds of demonstrators staged peaceful protests in Afghanistan, but ones in Laghman, Kunduz and Logar provinces turned violent.
"The culprits of the burning of the holy Quran should be arrested and hanged to death in public," said Mohammad Karim, one of 1,000 protesters who burned tires and threw stones at Afghan police in Mohammad Agha district of Logar province, south of Kabul. "We don't accept it when they say 'We apologize. We apologize.' We don't want Americans here at all."
Laghman provincial police chief Abdul Rahman Sarjang said about 1,000 protesters threw stones at Afghan security forces, smashed windows of government buildings and tried to attack the nearby governor's house in the provincial capital of Mehterlam.
In Kunduz, the capital of Kunduz province in northeast Afghanistan, more than 1,000 protesters threw rocks at government buildings and a U.N. office, said Sarwer Hussaini, a spokesman for the provincial police. He said the police fired into the air to try to disperse the crowd. Dr. Saad Mukhtar, health department director in Kunduz, said at least three protesters died and 50 others were injured in the melee.
In a statement, the U.N. mission in Afghanistan said the U.N. had deep respect for the Islamic faith and understood why Muslims were upset about the desecration of their holy book, but urged the demonstrators to exercise self-restraint and not let militants use the protests to foment violence.
Associated Press writers Patrick Quinn, Heidi Vogt and Amir Shah in Kabul, Robert Burns in Washington and Slobodan Lekic in Brussels contributed to this report.