Two people died when protesters turned on the US airbase at Bagram - although the US has had no involvement with the images, which originated in Denmark.
Meanwhile in Somalia, a teenage boy died after protesters attacked police.
Iran announced it was halting trade with Denmark, as protesters pelted the Danish embassy with petrol bombs.
Police fired tear gas in a bid to keep back hundreds of angry demonstrators, some of whom attempted to scale the wall into the embassy compound. Earlier, the Austrian embassy in Tehran came under attack.
The violence follows attacks on Danish embassies in Syria and Lebanon over the weekend. The cartoons were first published in a Danish newspaper.
There are protests again outside the European Union offices in Gaza, following demonstrations there last week.
'Test our feelings'
Hundreds of people took part in the morning demonstration in Afghanistan's Laghman province, in a second day of protests in the city.
Three people died when police fired on protesters after a police station came under attack, a government spokesman said.
Demonstrators shouted "death to Denmark" and "death to France". They called for the expulsion of diplomats and soldiers, who were sent by both countries as part of international efforts in the US-led "war on terror".
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
30 Jan: Gunmen raid EU's Gaza office demanding apology
31 Jan: Danish paper apologises
1 Feb: Papers in France, Germany, Italy and Spain reprint cartoons
4 Feb: Syrians attack Danish and Norwegian embassies in Damascus
5 Feb: Protesters sack Danish embassy in Beirut
"They want to test our feelings," protester Mawli Abdul Qahar Abu Israra told the BBC.
"They want to know whether Muslims are extremists or not. Death to them and to their newspapers," he said.
In Bagram district, a peaceful protest in the morning turned violent when around 300 "bandits and gangsters" tried to enter the US base, local police chief Mawlana Sayed Khel told the BBC.
A shoot-out with police left two protesters dead, and six police officers injured, he said.
Elsewhere, hundreds protested in Kandahar, Mazar-e-Sharif and the north-eastern province of Takhar. Some 200 demonstrators gathered outside the Danish embassy in the capital, Kabul.
Afghan President Hamid Karzai reiterated his condemnation of the cartoons and called on western nations to take "a strong measure" to ensure such cartoons do not appear again. "It's not good for anybody," he told CNN.
In the autonomous Somali region of Puntland, demonstrators marched through the port city of Bosaso, shouting anti-Western slogans and converging on the UN and international aid agency buildings.
A 14-year-old boy was reportedly trampled underfoot as police fired into the air to try and disperse an increasingly angry crowd.
Peaceful protests were held in several other Somali towns.
The cartoons first appeared in a Danish newspaper in September and caused outrage among Muslims, who consider any images of Muhammad offensive.
One of the cartoons shows Muhammad wearing a bomb-shaped turban.
Newspapers across Europe republished the pictures last week, saying they were defending freedom of expression.