(All times GMT)
Al Jazeera's bureau in Mogadishu was ordered to close in a letter from the national security agency.
"They did not say why they did it," said Mohammed Adow, Al Jazeera's Somalia correspondent.
"It is a sign that the government is becoming more cagey and more intolerant of the press."
Two private radio stations based in the capital were also ordered to close.
"[The stations] have been ordered to cease operations because they violated the ethics of the media by misinforming about the reality in Somalia," Hussein Mohamed Muhamoud, a government spokesman, said.
Wadah Khanfar, Al Jazeera's director general, said in a statement: "Al Jazeera, while expressing its disappointment of the decision to close our office ... reasserts its commitment to the principles of the free press and defends the right of viewers to know what happens across the world with impartiality and integrity."
Amina Sabriye, a mother-of-six, told the AFP news agency as she fled from the Shirkole neighbourhood: "All the fighting sides are making warlike statements and are preparing for war.
"The worst decision is to stay one more day in Mogadishu."
Mohamed Mukhtar Sadiq, another resident, said: "I have never seen a mass exodus at this scale in the recent years."
Salad Ali Jelle, the deputy defence minister, told a news conference on Thursday: "The fighting in Mogadishu will not stop until we defeat them [the insurgents].
"We will pursue our aim of stabilising Mogadishu. This plan will not be hampered by a few individuals," he said, referring to a planned government crackdown on armed groups in the capital.
He also said al-Qaeda had named Aden Hashi Ayro as its leader in Mogadishu and he had commanded the recent violence.
"After Somali terrorists made consultations with al-Qaeda, Ayro was named as chief of al-Qaeda in Mogadishu," he said.
The Hawiye clan, seen by many as the instigators of many of the recent attacks in Mogadishu, have rejected the order to leave and accused the government of planning an assault against the clan.
"There was peace... in Somalia for six months while the Union of Islamic Courts were in power"
Send us your views
Most of the Islamist Courts Union fighters, who controlled Mogadishu until they were forced out by Ethiopian and Somali interim government forces in late December, are drawn from the clan.
"We see this war as an act of aggression," Ahmed Dirie, a clan spokesman, said.
At least 40,000 people have been displaced by violence since the start of the year.
After Ethiopian troops entered Somalia to help the interim government defeat the Islamic Courts, the movement vowed to conduct a guerrilla war against them.
The bodies of several soldiers either from the Somali interim government forces or the Ethiopian army were apparently dragged through the streets by a crowd in fighting on Wednesday that left about 60 people dead.
However, in an interview with Al Jazeera's Andrew Simmons, Meles Zenawi, the Ethiopian prime minister, denied that his soldiers were trapped in a dangerous "quagmire" in Somalia.
"We are not in a quagmire now; we have completed our first phase of withdrawal, we'll complete our second phase of withdrawal in a few days' time and things are improving in Somalia," he said.
Zenawi also said that the security problems in Mogadishu had been exaggerated.
"Of course, there are challenges in Mogadishu, but the rest of Somalia is very stable and even in the case of Mogadishu, taking into consideration the fact that this is a city of 2.2 million people, awash with guns, the type of security challenge we currently face are not all that unexpected or alarming," he said.
One of the leaders of the Islamic Courts has defended the violence, saying people had a right to defend themselves against foreign invasions.