The Islamists once again control much of southern Somalia
All Ethiopian troops will leave Somalia by the end of the year, a foreign ministry spokesman has announced.
Ethiopia sent thousands of soldiers into Somalia two years ago to help government forces oust Islamists from the capital, Mogadishu.
But their presence has been deeply unpopular with many Somalis.
Somali President Abdullahi Yusuf recently admitted that his forces only control parts of the capital and the central town of Baidoa.
Despite being forced from power in Mogadishu, Islamist forces have rallied and stage frequent attacks against Ethiopian and government soldiers.
Hardline Islamists have refused to take part in peace talks until the Ethiopians left Somali territory - the two countries have twice fought border wars.
The government is also deeply divided between President Yusuf and Prime Minister Nur Hassan Hussein.
Ethiopian foreign ministry spokesman Wahide Belay said that the deadline for the pull-out was in a letter sent to UN Secretary General Ban Ki-moon and African Union Commission Chairman Jean Ping on Tuesday.
"We have done our job and we are proud of it, but the expectations that we had from the international community were never fulfilled. But that said, we will withdraw in a responsible manner," he told the AFP news agency.
The US supported the Ethiopian move into Somalia but calls for UN peacekeepers to be sent have never materialised.
This is not the first time the Ethiopians have said they would withdraw but the BBC's Elizabeth Blunt in Addis Ababa says what is new is the lack of conditions or provisos.
It has previously said it would not pull out in a way that would leave a vacuum or destabilise the situation.
There are believed to be about 2,000 Ethiopian troops in Somalia - sharply down from the 12,000 who first intervened.
The Ethiopian withdrawal was also part of a peace deal agreed recently between the government and moderate Islamists.
Some analysts fear fighting could increase after the Ethiopians leave.
There is a small African Union peacekeeping force in Mogadishu but analysts say they are unlikely to fight off the advancing Islamists.
The AU Commission Chairman warned that the AU force could also leave if government in-fighting continues.
"If the transitional government continues to quarrel, if those we came here to help can't agree and the Ethiopians pull out lock, stock and barrel... and African troops too decide to leave, then we have the worst possible scenario," he said, reports the AFP news agency.
Some analysts fear a power vacuum after the Ethiopians leave
Horn of Africa analyst Roger Middleton, from the Royal Institute of International Affairs (RIIA), says morale is low in Ethiopia's army and troops are needed on the border with Eritrea.
But he said the situation may not improve and could become more complicated.
"It is possible that the government and ARS [moderate Islamists] form a broad-based government," he said.
"But a more likely scenario is a proliferation of armed groups fighting each other."
Rashid Abdi, a Somalia analyst at the International Crisis Group (ICG) think-tank, said the Ethiopians may now use troops and air power against the Islamists, instead of having troops on the ground, who are vulnerable to attack.
"The Ethiopians are at the end of their tether because of the squabbling in the interim government, which they have backed at such enormous human and financial cost," he told Reuters news agency.
Some 10,000 civilians have been killed since 2007, Reuters reports.
Donors say that up to three million people - almost half the population - need food aid.
Somalia has not had an effective national government since 1991.
The anarchy has also spread to the seas, which attacks by pirates have made the most dangerous in the world.