"There was a change in the security situation and we decided that it was necessary due to the situation locally," said Erik Laursen, a spokesman for the ministry, who added the decision was based on new intelligence. He did not elaborate.
Embassy employees in Algiers were relocated a few days ago, while those in Kabul were moved Wednesday. They continue to work remotely, Laursen said.
He could not say how long the staff would remain at their new locations.
The Danish Security and Intelligence Service earlier this month warned of an aggravated terror threat level against Danish interests in North Africa, the Middle East, Pakistan and Afghanistan. It said the threat level had sharpened since Danish newspapers reprinted earlier this year a cartoon depicting the Prophet Mohammad as a protest over a plot to murder the cartoonist.
The cartoon depicts Mohammad wearing a bomb in his turban. It was one of 12 drawings of the Prophet that sparked riots in the Muslim world in 2006 after originally being printed in a Danish newspaper in 2005.
Most Muslims consider any depiction of the founder of Islam as offensive.