A Foreign Ministry spokesman said Denmark was "not satisfied with the security situation".
At the same time, Pakistan said it had recalled its ambassador to Denmark for what it called "consultations over the cartoon controversy".
The images, first printed in Danish newspaper Jyllands-Posten, have sparked anger across the Islamic world.
In Hong Kong, more than 2,000 Muslims stage a peaceful anti-cartoon march.
Denmark said its embassy staff would remain in Pakistan and denied that diplomatic ties were affected.
30 Sept 2005: Danish paper publishes cartoons
20 Oct: Muslim ambassadors complain to Danish PM
10 Jan 2006: Norwegian publication reprints cartoons
26 Jan: Saudi Arabia recalls its ambassador
31 Jan: Danish paper apologises
1 Feb: Papers in France, Germany, Italy and Spain reprint cartoons
4-5 Feb: Danish embassies in Damascus and Beirut attacked
6-12 Feb: Twelve killed in Afghanistan as security forces try to suppress protests
13-17 Feb: Violent protests break out across Pakistan
But it issued a new travel warning for Pakistan and urged Danes in the country to leave as soon as possible.
"The demonstrations that are currently being held in Pakistan have created an atmosphere of very strong antipathy against Denmark and Danes," the ministry said in a statement.
Pakistan, meanwhile, brought its ambassador back from Copenhagen for consultations over the cartoon issue.
The BBC's Julian Isherwood says this is in effect putting diplomatic relations between the two countries on hold.
This is the fifth embassy that Denmark has closed since the cartoon row sparked. Missions in Iran, Syria, Lebanon and Indonesia are all temporarily shut.
Protests continued across Pakistan on Friday and a radical Islamic leader was detained to prevent him leading protests.
Hafiz Mohammed Saeed was held in Lahore as he prepared for a rally after Friday's prayers, his spokesman said.
Thousands have taken part in street protests across Pakistan
Mr Saeed is the founder of the Lashkar-e-Toiba, a banned militant group fighting in Indian-administered Kashmir. He now heads the Jamaat-ud-Dawa, a radical group that is under government surveillance.
In Karachi, Pakistan's biggest city, police fired tear gas and used batons to disperse some 2,000 protesters who blocked a major street. Some 60 people were arrested.
Dozens of protesters were detained by police in Lahore, Multan and Faisalabad.
Tens of thousands of police are out on patrol in major cities and most schools and colleges have been closed to prevent students from joining the protests.
The BBC's Barbara Plett says this is one of the worst weeks of street violence Pakistan has seen in years, with rallies turning into major acts of civil disorder.