Ethiopian and government troops are in control of the Somali capital, Mogadishu, after nine days of battles, the prime minister says.
Hawiye clan fighters and Islamists are battling the government
Ali Mohamed Ghedi said the worst of the fighting against Islamists and clan gunmen was now over.
Columns of tanks were deployed and reinforcements sent to Mogadishu from other parts of Somalia.
Earlier, a BBC correspondent in the city said the battles were the heaviest in recent days, spreading to new areas.
United Nations humanitarian relief co-ordinator John Holmes has described the situation in Somalia as critical.
He said up to 400,000 people had fled Mogadishu but aid was reaching just 60,000. A doctor who runs one of Mogadishu's hospitals estimates that two-thirds of the city's one million residents had left.
Some 300 people have been killed in the recent clashes, after 1,000 deaths last month, local human rights group say.
Mogadishu residents say government forces have taken control of some northern suburbs from the insurgents.
"We hope to completely conclude the war tomorrow, and government forces will secure the capital," Mr Ghedi said.
But some correspondents in Mogadishu have questioned Mr Ghedi's assessment - they say there are still reports of heavy fighting, and artillery and machine-gun fire can be heard across the city.
Somali Education Minister Ismail Mohamoud Hurre said the deaths and violence were a price worth paying to return normality to the country, which has not had a functioning national government for 16 years.
"The Ethiopian forces are doing very well, stopping the Jihadist elements from causing instability," he told the BBC's Network Africa programme.
"We have to bite the bullet."
But a UK think-tank has strongly criticised last December's operation to oust an Islamist group which had taken control of Mogadishu and much of southern Somalia.
"Genuine multilateral concern to support the reconstruction and rehabilitation of Somalia has been hijacked by unilateral actions of other international actors - especially Ethiopia and the United States - following their own foreign policy agendas," said the Chatham House report.
"Whatever the short-term future holds, the complex social forces behind the rise of the Islamic Courts will not go away," the authors said.
The Union of Islamic Courts controlled Mogadishu for six months last year - reuniting the capital for the first time since 1991.
The Islamist fighters have been joined by gunmen from the Hawiye clan, which does not back the government.
Donors and diplomats have accused the government of hindering the aid effort with bureaucratic obstacles.
The government says its checks on aid shipments are necessary to prevent insurgent attacks.
Many of the casualties are civilians
Somalia has not had a functional government since 1991.
Peace talks led to the formation of a transitional government in 2004, but it has so far failed to take full control of the country.
Ethiopian troops announced they had begun to withdraw, to be replaced by an African Union peacekeeping force, but only 1,200 of the 8,000 troops the AU says it needs have been deployed.