An Afghan mob apparently angry over a Quran burning in Florida set upon a United Nations compound Friday, killing as many as 20 employees and setting fire to several compound buildings.

The attack, which may be the deadliest assault on the UN in Afghanistan, grew out of a protest in response to news that US pastor Terry Jones oversaw a Quran burning on March 20. Mr. Jones drew worldwide criticism last year for threatening to burn Qurans on the anniversary of 9/11.

The UN is still assessing the scope of damage and determining the exact death toll at its offices in Mazir-e-Sharif, a typically quiet city in northern Afghanistan.

While the outburst of civilian violence aimed at the UN is rare, this attack seems to show that anger over the foreign presence in Afghanistan is coming to the surface.

“In general you can easily rally people around issues such as insulting the Koran and insulting the prophet," says Martine van Bijlert, codirector of the Afghanistan Analysts Network. "But other than that I think there is also an increasing tension and annoyance with the international presence and so a demonstration like that does get mixed up with more general suspicions about the intentions of the internationals.”

Today's violence came after two or three hours of protests over the Florida Quran burning, which was broadcast online. Demonstrators started throwing stones at the UN compound then attempted to climb its walls and attacked guards. In addition to as many as 20 UN workers being killed, at least four protestors died. The UN’s chief of mission in the city was injured but survived the attack.

Afghanistan saw several protests when Mr. Jones previously planned to burn the Koran on the anniversary of 9/11 last year. The controversial pastor of Dove World Outreach Center in Gainesville, Fla., decided not to go through with it at the time, largely due to a phone call from top Afghanistan commander US Gen. David Petraeus, who warned that the defamation of the Quran would likely cost the lives of US service men and women Afghanistan.

Jones decided to go through with the burning on March 20 after serving as judge in a “trial” of the Muslim holy book. He found it “guilty” of “training and promoting terrorist activities ... death, rape, torture of people worldwide” and crimes against women and minorities.

A smaller demonstration with about 100 protestors also took place in front of the US Embassy in Kabul. Demonstrators called for US forces to leave Afghanistan. There were no reports of violence or injury.

Friday's attack may cause the UN to reconsider the extent of its presence here. After the 2009 attack against UN guesthouses in Kabul, the UN pulled 200 workers from Afghanistan and withdrew an additional 400 from field postings to safer urban locations.

Less than two weeks ago, Afghan President Hamid Karzai announced that Mazir-e-Sharif would be among the first seven areas to be transitioned to the control of Afghan security forces. The UN deaths could certainly generate high-level discussions about the transition scheduled for mid-July.

“If anything what this attack demonstrates is that it will be a long time before transition is possible,” says Candace Rondeaux, the International Crisis Group’s senior analyst for Afghanistan. “If you can’t deal with a public demonstration and control it then how can you deal with a sophisticated insurgency that’s armed to the teeth?”