What started as a mass anti-American demonstration in a city in northern Afghanistan ended as the worst attack on the United Nations in the country.
Eight of their workers have been executed in Mazar-i-Sharif, and UN officials say the number killed could yet rise to 20.
The victims included five guards from Nepal, a Norwegian army officer and civilian staff from Sweden and Romania.
Reports indicate that five protesters were killed in the violence which erupted on the day of prayer, with the demonstrators angered by the burning of the Koran in the United States last month.
Local residents claim about 2,000 demonstrators attacked UN guards stationed outside the compound, while officials say investigations into the incident are continuing.
Mazar-i-Sharif in the north of the country was one of three cities where protesters held anti-American demonstrations.
In Herat, crowds gathered in a sports stadium, with some chanting: “Death to America”. Banners called for the US troops to leave Afghanistan.
There were similar scenes in Kabul, where protesters marched outside the American embassy. The killings have been condemned by President Barack Obama.