At least 11 people were killed -- including seven United Nations workers -- after protesters angry about the burning of a Qur'an by a small American church attacked a UN compound in northern Afghanistan.

The demonstration Friday in Mazar-i-Sharif began peacefully but turned violent after some members of the crowd took weapons off the UN compound's guards and began shooting, then entered the buildings and lit fires.

Protesters were angry that a small church in Florida burned a copy of the Qur'an last month. The pastor of the church, Rev. Terry Jones, had threatened to do so last year but backed down after sparking outrage among millions of Muslims around the world.

Dan McNorton, a spokesperson for the UN Assistance Mission in Afghanistan, said the seven foreigners killed in the attack included four foreign security guards.

Swedish Foreign Minister Carl Bildt said a 27-year-old UN worker from his country named Joakim Dungel died. Norway's defence ministry identified another victim as Lt. Col Siri Skare, a 53-year-old female pilot.

The UN guards were from Nepal, according to Gen. Daud Daud, the commander of Afghan National Police in a number of northern provinces. The seventh foreigner killed was Romanian, a Western official told The Associated Press.

Local authorities said four Afghan protesters also died in the violence. Nearly two-dozen civilians were injured, Interior Ministry spokesperson Zemeri Bashary said.

Abdul Karim, a local police officer, reported seeing several bodies in the compound, some with wounds to the face, head or body and others riddled with bullets.

Afghan investigators claimed that insurgents may have filtered into the crowd. Police arrested more than 20 people -- including the person they believe orchestrated the attack. Deputy provincial police chief Rawof Taj said the suspected leader is a militant from Kapisa province, 400 kilometres southeast of Mazar-i-Sharif.

The top UN official in the country, Staffan de Mistura, was travelling to Mazar-i-Sharif to deal with the situation, according to a spokesperson.

The city has been considered one of Afghanistan's safer areas. It's slated to become one of the first to be policed by Afghan security forces beginning in July.

In Nairobi, Secretary-General Ban Ki-moon, called the attack "cowardly" and said it "cannot be justified under any circumstances."

Afghan President Hamid Karzai issued a statement late Friday describing the killings as an "inhumane act" that was "against the values of Islam and Afghans."

U.S. President Barack Obama condemned the attack and said the work of UN staff "is essential to building a stronger Afghanistan for the benefit of all its citizens."

He also pleaded for calm, and asked "all parties to reject violence and resolve differences through dialogue.

The Qur'an burning also sparked two peaceful anti-American demonstrations Friday near the U.S. embassy in Kabul and in Herat, a city in Western Afghanistan.

Jones said he did not believe his church's actions led to the violence. That was only "an excuse," he said.

U.S. State Department spokesperson Mark Toner said the Qur'an burning was "an isolated act done by a small group of people and ... does not reflect the respect the people of the United States have toward Islam."

Last week, Karzai described it as a "crime against a religion."

With files from The Associated Press