US naval forces have deployed off the Somali coast to prevent leaders of defeated Islamist militias escaping.
Somali soldiers may struggle to maintain order in Mogadishu
Kenya has also significantly tightened border security to stop an influx of fleeing fighters, as aid agencies called for help for genuine refugees.
Uganda's president is travelling to Ethiopia to discuss forming an African force to stabilise the country.
A two-week advance by Ethiopian troops swept the Islamist militias from areas they had controlled for six months.
The militias - known as the Union of Islamic Courts - had brought a degree of stability to large areas of the formerly lawless country.
But Ethiopia accuses them of al-Qaeda links, and sent heavily-armed troops into Somalia to back up forces loyal to the weak transitional government.
Islamists say their retreat from the troops is tactical and have threatened to launch an insurgency.
US State Department spokesman Sean McCormack confirmed the deployment of navy ships.
"We would be concerned that no leaders who were members of the Islamic Courts which have ties to terrorist organisations including al-Qaeda are allowed to flee and leave Somalia," he said.
Kenya has deployed tanks and helicopters on its border, as militias fleeing south clashed near the border with Somali and Ethiopian troops.
Foreign Minister Raphael Tuju told a news conference that the border was closed, but government spokesman Alfred Mutua later told the BBC that legitimate refugees were being allowed entry.
"We are conducting very thorough and rigorous security vetting to ensure that we don't get people coming in carrying weapons, people coming in who are Islamists," he said.
"And so that is causing delays, but we are making sure that everyone who comes in as a refugee... we are driving them to a camp within Kenya which is run by the United Nations."
Mr Mutua denied reports that 600 Somali refugees, mainly women and children, had been deported from the border transit camp at Liboi.
A spokeswoman for the UN refugee agency UNHCR said they had been denied access to the camp by Kenyan authorities, but witnesses had reported Somalis being deported in government trucks.
UNHCR head Antonio Guterres said in a statement that deserving Somali civilians should be entitled to seek asylum in Kenya.
'Inclusive political process'
On Wednesday, Ethiopian and Somali government forces captured the border town of Doble, one of the final places held by the Islamist militias. Four thousands refugees were reported to be stranded in the area.
Between 600 and 700 militia fighters fled the town on Tuesday night, a BBC correspondent said.
Somali Prime Minister Ali Mohamed Ghedi has said that he believes the bulk of the fighting is over.
Attention is now focusing on how to stabilise the country.
After European members of the Somali Contact group met in Brussels, Swedish Foreign Minister Carl Bildt called for peace talks.
"There has to be a withdrawal of the Ethiopian forces. There has to be a political process, an inclusive political process in Somalia."
Ugandan President Yoweri Museveni is due in Ethiopia on Thursday for talks on a possible African peacekeeping force for Somalia. He has already offered to commit 1,000 troops.
The African Union commissioner for peace and security said he hoped African countries would contribute to a peacekeeping force.
"I still hope that key AU members will be glad to associate their name and the name of their country in what I believe is the most important peace undertaking in the recent history of Africa," Said Djinnit told the BBC's Network Africa programme.
Thursday is also the deadline for Somalis in the capital to hand in their weapons, but slow progress has been made so far.