The United Nations Security Council has approved the deployment of an African Union peacekeeping force to Somalia.
Mortar attacks killed 16 in Mogadishu on Tuesday
Somalia has been beset by the heaviest fighting between insurgents and government troops since the withdrawal of Islamist militias last year.
The 8,000 strong force has a mandate to help stabilise the situation, but only 4,000 troops have been pledged so far.
An insurgent leader has warned they will attack any foreign troops, whether they are supported by the UN or not.
"The UN should keep its hand off our country because the Islamic forces are ready to fight any foreign troops whether they are blue helmet or black helmet," said an insurgent leader claiming to be part of a newly formed group called the Popular Resistance Movement in the Land of the Two Migrations.
The UN resolution urged all AU member states to contribute troops. Moreover, a UN force may arrive in six months.
Specifically, the resolution, drafted by Britain, authorises the 53 AU member states to deploy for six months a mission to Somalia which will be provided with all the means necessary to accomplish its mandate.
The council has asked UN Secretary-General Ban Ki-moon to investigate the possibility of a UN peacekeeping operation.
On Tuesday, fierce battles prompted thousands of residents to flee the Somali capital Mogadishu.
Ethiopian soldiers have started to withdraw after helping the government oust the Islamists.
So far only Uganda, Burundi, Nigeria and Ghana have agreed to send soldiers to the mission.
Uganda is expected to be first to deploy troops and will announce details later on Wednesday.
They have proposed sending 1,500 soldiers in a phased operation.
After 16 years without an effective national government, Mogadishu is awash with weapons.
Some Islamist leaders vowed to start a guerrilla war after they were driven out of Mogadishu in December.
But no-one has claimed responsibility for the spate of recent attacks.
The interim government of Somalia has ordered the three main local media organisations operating in the capital to stop reporting on military operations and the displacement of civilians.
The deputy head of the National Security Agency, General Nur Muhammad Mahamud, told HornAfrik radio, Benadir radio and the Shabelle Media Network that as Somalia was under martial law, the media was not allowed to report freely.
He said that if the media groups continued to report on the violence, they would be shut down.
But a manager at HornAfrik told the BBC that his radio station would not be intimidated by the interim government and that it was continuing to broadcast reports of the ongoing violence in Mogadishu.