The UN says protesters who placed corpses in front of their headquarters in the Central African Republic (CAR) were using the bodies for "propaganda".
"Some people are using dead bodies... to say that we have killed civilians," a UN spokesman told the BBC.
On Wednesday, demonstrators calling for an end to violence put 17 bodies outside the UN building in Bangui.
They said the dead were innocent civilians killed in clashes between UN troops and armed groups.
But the UN says the dead were armed criminals who had been targeting peacekeepers and government soldiers.
"They shot at our peacekeepers and we returned fire," UN spokesman Vladimir Monteiro said. "The bodies resulted from the clashes."
"We condemn the fact that some people are using dead bodies for a kind of propaganda," he added.
UN troops began an operation on Sunday to disarm vigilantes in the PK5 neighbourhood of Bangui.
A self-styled Muslim militia is based there, purporting to protect residents.
Mr Monteiro told the BBC that the UN would continue the operation despite the angry protests.
CAR was plunged into turmoil in 2013 when Muslim rebels from the Seleka umbrella group seized power in the majority-Christian country. A band of mostly Christian militias, called the anti-balaka, rose up to counter the Seleka.
A new government elected in 2016 has failed to bring peace to the mineral-rich nation which has been unstable since its independence from France in 1960.
Why did the clashes erupt?
The UN mission, known by the acronym Minusca, says it launched the military operation after residents complained about extortion and violence by the armed group.
It said in a statement on Tuesday that its soldiers had been attacked: "For four hours, the Minusca force had to push back heavily armed elements of criminal gangs who deliberately opened fire on the international forces, who fired back."
A demonstrator told Reuters news agency the UN forces had shot at civilians during Tuesday's operation.
"We, ourselves, no longer understand anything," he said. "Does their mission consist of shooting at civilians?"
Mayor Atahirou Balla Dodo of the Bangui district in which the PK5 neighbourhood is located told Reuters a total of 21 people had been killed in the clashes.
He said protesters had taken 17 bodies from the morgue but had left four others, two women and two children.
UN troops and the local Red Cross team later removed the bodies.
Medical charity Medecins Sans Frontieres (MSF), which operates one of the main hospitals in Bangui, said it had treated more than 40 people for gunshot wounds on Tuesday.