Nine people have been killed in the Afghan city of Kandahar during a demonstration against the burning of a Koran in the US, officials say.
Hundreds of people took part in the protest. Gunfire was heard and cars were set on fire.
On Friday, seven UN workers were killed after a protest over the same issue in in the northern city of Mazar-i Sharif.
It was the worst attack on the UN mission in Afghanistan since the international invasion in 2001.
A large and angry crowd surged through the streets of Kandahar, chanting "They have insulted our Koran" and "Death to America", the BBC's Paul Wood reports from Kabul.
The authorities in both Kandahar and Mazar-i Sharif blamed the Taliban for the attacks. However, the Taliban has rejected the accusation.
"The Taliban had nothing to do with this, it was a pure act of responsible Muslims," spokesman Zabiullah Mujahid told the Reuters news agency by phone from an undisclosed location.
"The foreigners brought the wrath of the Afghans on themselves by burning the Koran," he said.
UN staff remain on maximum security alert and under lockdown, our correspondent says. However, there is no move yet to evacuate them from Afghanistan, as happened in 2009 after an attack on a UN guesthouse.
Separately, three insurgents were killed when they attacked a Nato base.
They were stopped before they could enter the compound, Nato and Afghan police said.
At least one was wearing a burka, news agencies reported on Saturday, quoting police sources.
UN Secretary General Ban Ki-moon condemned the violence in Mazar-i Sharif as "outrageous and cowardly". Afghan President Hamid Karzai said it was inhumane and against Islamic and Afghan values.
In all, 14 people were killed.
Local police told the BBC that 27 people had been arrested following the demonstration in Mazar-i Sharif.
The demonstrators were angered by the actions of US Pastor Wayne Sapp, who set light to a copy of the Koran at a church in Florida on 20 March.
The burning took place under the supervision of Pastor Jones, who last year drew condemnation over his aborted plan to burn copies of the Koran on the anniversary of the 9/11 attacks.
Pastor Jones has denied responsibility for the lethal protests in Afghanistan.
Witnesses said the protest - which began outside the central Blue Mosque after Friday prayers - began peacefully but suddenly turned violent.
The crowds moved to outside the UN compound, where a small group broke away.
Several demonstrators were killed by guards at the compound, who were then overpowered by the mob.
Munir Ahmad Farhad, a spokesman for the provincial governor, said the group seized weapons from the guards and opened fire before storming the building.
A state of emergency has now been declared in the city, Afghan intelligence sources told the BBC. All roads in and out of Mazar have been blocked and cars are being checked, says the BBC's Bilal Sarwary.
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."
One of the dead was a Swedish national, while another came from Norway. The other foreign victims are believed to be a Romanian and four Nepalese guards.
US President Barack Obama 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.
Local police spokesman Lal Mohammad Ahmadzai told reporters that two of the UN staff had been 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.
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".
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."
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.