(CNN) -- Islamist militants took almost full control of Mogadishu on Thursday, less than 24 hours after Ethiopian troops withdrew from Somalia's capital, a witness reported.

Ethipian troops invaded Somalia in 2006.

The Ethiopian forces pulled out their last remaining bases in the city late Wednesday after two years propping up Somalia's transitional government.

Forces from different Islamist groups -- including the hard-line al-Shabab, which the United States has designated a terror organization -- immediately seized every base the Ethiopians abandoned.

"The city is almost under Islamist rule," said a local journalist who did not want his name revealed. "You can hear different names of the Islamist groups taking control in many parts of the city."

The journalist said the militants were in "full force" in most of Mogadishu. However, they had yet to claim control of the city's seaport, the presidential palace and a major junction on the south side.

Ethiopia invaded Somalia in December 2006 to install a U.N.-backed transitional government in Mogadishu after a decade and a half of near-anarchy.

The invasion had the blessing of the United States, which accused the Islamic Courts Union that captured Mogadishu earlier that year of harboring fugitives from al Qaeda.

The Islamists responded with a guerrilla campaign against government and Ethiopian troops. Efforts to replace the Ethiopians with an African Union-led peacekeeping mission faltered as the violence worsened, and heavy fighting in Mogadishu and other cities drove hundreds of thousands from their homes.

Don't Miss

The lawlessness also spilled onto the seas off the Horn of Africa, where international vessels are routinely hijacked by suspected Somali pirates who demand large ransoms. And the transitional government was wracked by a power struggle between Prime Minister Nur Hassan Hussein and President Abdullahi Yusuf, who resigned in December.

Hussein said Thursday that he would run for president now that Ethiopian troops had gone.

Ahmed attempted to fire Hussein for being ineffective. But Hussein said the president did not have that power, and the vast majority of members of parliament backed Hussein in a vote of confidence.