Hundreds of civilians were reported to be fleeing their homes in central Somalia yesterday as the prospect of a war between Islamist militants and government forces, backed by Ethiopian troops and artillery, appeared to draw closer.

The exodus was under way in the area around Baidoa, the last big town under the control of the western-backed transitional government. Baidoa is under siege on three sides by fighters from the Union of Islamic Courts (UIC) movement and rival forces are reportedly only a few miles apart in some places.

The UIC, which controls the capital Mogadishu and most of southern Somalia, has given Ethiopia until Tuesday to withdraw its troops from the country. If it fails to do so the Islamists, who are backed by Ethiopia's enemy, Eritrea, say they will attack. Ethiopia, which officially denies having combat troops in Somalia, has rejected the ultimatum.

Western diplomats are seeking ways to bring the Islamists and the Somali government together but little progress has been made. "We still have a tiny window of opportunity to avert war," said a European diplomat in Nairobi yesterday. "But it needs a huge effort ... to get both sides talking."

The US, which tacitly backs Ethiopia's intervention, pushed through a UN security council resolution this month authorising an African protection force to enter Somalia in support of the government. The UIC responded by calling for jihad against any foreign forces sent to the country. The US embassy in Nairobi condemned the UIC's ultimatum yesterday as "irresponsible" and called for negotiations to resume. "Given the existing, heightened tensions in Somalia, this ultimatum further destabilises the situation and undermines international and regional efforts to encourage credible dialogue," the US statement said.

The African Union also voiced alarm yesterday, calling on members to urgently contribute troops to the protection force.

"Somalia has remained a non-state and we have allowed things to rot," said Alpha Oumar Konare, the AU's chairman. "Obviously we are not going to wage war. But there can be no balanced dialogue if the transitional government is not helped and supported." The UN's envoy, François Lonsény Fall, urged a quick resumption of the so-called Khartoum dialogue that stalled in the autumn. Those talks are due to resume on Tuesday.

But hopes that conflict can be avoided faded after Ali Mohamed Gedi, Somalia's prime minister, said war seemed inevitable and his troops were ready for the fight. Meles Zenawi, Ethiopia's prime minister, said his country hoped to avoid war but complained that it was being attacked by the UIC and its Ethiopian Muslim allies. "Since last summer the Islamic Courts have been training and equipping and smuggling armed elements - hundreds of them - into Ethiopia and they have clashed with the security services," Mr Zenawi said recently.

While the two-year-old government has failed to win support from the Somali population, the Islamists have widespread approval. Having kicked the warlords out of Mogadishu in June, and brought order to the city for the first time in 15 years, they quickly spread their influence. Ethiopia is distrusted by most Somalis, who are wary of foreign intervention.

The Islamists' rise also worries the US, which accuses them of links to al-Qaida. In a bid to slow the courts' progress Washington backed the Mogadishu warlords against them - unsuccessfully.