Turkey, which had formed an emerging alliance with Egypt's ousted Islamist leader Muhammed Morsi, on Thursday slammed the democratically elected leader's overthrow by the military as "unacceptable" and called for his release from house arrest.

Turkish Prime Minister Recep Tayyip Erdogan's Islamic-rooted government has been watching developments in Egypt with concern as the armed forces ousted Morsi, an Islamist and Egypt's first democratically elected president.

Turkey last month was hit by a wave of protests against Erdogan's perceived authoritarianism and his attempts to impose his conservative views in a society that is ruled by secular laws. Morsi's removal follows protests by Egyptians angry over what they see as his efforts to impose control through the Muslim Brotherhood and his failures to deal with the country's multiple problems.

Erdogan's government has an aversion to military intervention in politics and since coming to power a decade ago, has curtailed the powers of the pro-secular Turkish military, which has staged three coups between 1960 and 1980 and forced an Islamic-led government out of office in 1997.

Last year, some 300 military officers were convicted for an alleged plot to topple Erdogan's government. Their case is being appealed.

Foreign Minister Ahmet Davutoglu said in a televised statement that Morsi was deposed illegally through a "military coup" and said democratically elected leaders should only be ousted through elections.

Underscoring the importance he attached to ties with Egypt, Davutoglu said he had cut short a visit to Asia to return to Turkey for consultations with Erdogan on developments.

"The toppling of a government that came into office through democratic elections, through methods that are not legal -- and what is worse, through a military coup -- is unacceptable, no matter what the reasons," Davutoglu said.

"It is important from the point of view of a national consensus that (leaders) who have been arrested are immediately released," he said.

Davutoglu also called for the start of the election process so that power in Egypt is immediately returned to "elected authorities."

Egypt's Muslim Brotherhood group had long viewed Erdogan's government as an Islamist success story, mixing a strong economy with Western ties and Islamic piety -- and the two had been working toward strengthening ties. Last year, Turkey pledged $2 billion in aid to boost confidence in Egypt's economy that was battered by a tourism slump, strikes and protests since the fall of authoritarian leader Hosni Mubarak in an uprising in 2011.

Earlier, Turkey's all-party parliamentary human rights commission also denounced Morsi's ouster while small protests were held in Ankara and Istanbul.