At least seven foreign UN workers have been killed after protesters stormed a UN compound in the Afghan city of Mazar-e Sharif, officials say.
The compound was set alight as hundreds protested over the burning of the Koran in a US church last month. Several demonstrators were killed by guards.
Witnesses said the protest began peacefully but suddenly turned violent.
A local police spokesman told the BBC the city was now under control and a number of people had been arrested.
Dan McNorton, spokesman for the UN mission in Afghanistan, said: "Three international Unama (United Nations Assistance Mission in Afghanistan) staff members were killed, and four international armed security guards were killed."
Initial reports said eight foreign UN workers had died.
Swedish Foreign Minister Carl Bildt later confirmed that one of the dead was a Swede, 27-year-old UN worker Joakim Dungel.
The Norwegian defence ministry said another of those killed was Lt Col Siri Skare, a 53-year-old female pilot. The other foreign victims are believed to be a Romanian and four Nepalese guards.
UN Secretary General Ban Ki-moon described it as "an outrageous and cowardly attack".
US President Barack Obama also condemned the attack "in the strongest possible terms", saying the work of the UN "is essential to building a stronger Afghanistan".
The top UN representative in Afghanistan, Staffan De Mistura, has flown to the area to handle the matter.
Witnesses said a crowd of several hundred staged a protest outside the Blue Mosque in the city after Friday prayers.
The crowds moved to outside the UN compound, where a small group broke away.
Munir Ahmad Farhad, a spokesman for Balkh province, said the group seized weapons from the guards and opened fire before storming the building.
Local police spokesman Lal Mohammad Ahmadzai told the BBC the attackers had used guns and knives.
He also told reporters that two of the dead UN staff were beheaded.
However, police Gen Abdul Rafu Taj said that "according to the initial reports... none were beheaded". He said they were shot in the head.
A number of suspected attackers have been arrested.
Officials have declared an emergency in the city - major roads in and out have been blocked.
Kieran Dwyer, director of communications for the UN mission in Afghanistan, said the UN workers had been trapped inside the compound and "hunted down" in what was an "overwhelming situation".
"These are civilian people, unarmed, here to do human rights work, to work for peace in Afghanistan - they were not prepared for this situation," he told the BBC.
Mr Dwyer said it was too early to tell how the attack happened or why the UN was targeted, but that the organisation would now take extra security measures.
But he added: "The UN is here to stay. We're here to work with the people to help them achieve peace, and this sort of thing just highlights how important that is."
On 20 March, Pastor Wayne Sapp set light to a copy of the Koran at a church in Florida.
The burning took place under the supervision of Terry Jones, another US pastor who last year drew condemnation over his aborted plan to burn copies of the Koran on the anniversary of the 9/11 attacks.
Protests were held in several other Afghan cities on Friday - which demonstrators in Herat had called a "day of anger", Afghanistan's Noor TV channel reports.
The BBC's Paul Wood in Kabul says Mazar-e Sharif is known to be a relatively peaceful part of the country, but that the Florida incident will raise questions of whether the city will be able to make the transition from foreign to Afghan security control later this year.
Our correspondent says that in a deeply religiously conservative country such as Afghanistan, that act has the power to inflame passions in otherwise peaceful areas.
Mr Jones told the BBC he was not responsible for the actions of the protesters.