A gunman killed two U.S. military advisers with shots to the back of the head Saturday inside a heavily guarded ministry building in Kabul, and NATO ordered military workers out of Afghan ministries as protests raged for a fifth day over the burning of Qur'ans at a U.S. army base.

The Taliban claimed responsibility for the attack at the Interior Ministry, saying it was retaliation for the Qur'an burnings, after the two U.S. servicemen — a lieutenant-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 that 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 Defence Minister Gen. Abdul Rahim Wardak called U.S. Defence Secretary Leon Panetta to apologize for the shooting and offer his condolences, Pentagon press secretary George Little said.

Security is tight in Kabul, 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.

6 Afghan police killed trying to defuse bomb

Afghanistan's Ministry of Defense says six Afghan soldiers were killed and 16 others wounded Saturday while trying to defuse a roadside bomb. 

The ministry says the soldiers died Saturday in Mukar district of Baghdis province in western Afghanistan.

—The Associated Press

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 Qur'an 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 carry out.

5th day of Qur'an burning protests

The incident came on the fifth day of protests across the country sparked by the burning of Qur'ans at a U.S. base.

Protesters threw rocks at police, government buildings and a UN office in eastern Afghanistan on Saturday, officials said.

At least 28 people have been killed and hundreds wounded since Tuesday, when it first emerged that Qur'ans and 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.

U.S. President Barack Obama and other U.S. officials apologized and said it was a terrible mistake, but the incident has sent thousands to the streets in this deeply religious country.   

Hundreds of demonstrators staged peaceful protests in Nangarhar and Paktia provinces, but ones in Laghman, Kunduz and Logar provinces turned violent.