People protest against the coup outside the parliament building in Ankara, Turkey, July 16, 2016.

ANKARA/ISTANBUL, July 16 (Xinhua) -- Turkish authorities said they regained control of the country on Saturday after thwarting an attempt by a military faction to seize power from the Turkish president.

The putsch attempt appeared not to have been backed by most senior military ranks, and Turkey's main opposition groups quickly condemned the attempted overthrow of the government.

Turkish Foreign Minister Mevlut Cavusoglu said that eight rebel soldiers escaped to Greece by a helicopter, CNN Turk reported.

Ankara demanded Athens to immediately extradite the rebels who sought political asylum, Cavusoglu was quoted as saying.

He added that Greek authorities promised that they would fully cooperate with Ankara.

At least 161 people were killed and 1,440 wounded in the coup attempt, Turkey's Prime Minister Binali Yildirim said earlier on Saturday.

"The situation is completely under control," Yildirim told reporters outside his Ankara office, flanked by Turkey's top general who had himself been held by the plotters.

He described the coup attempt as a "black stain" on Turkish democracy.

"Those who form the backbone of the coup have been taken into custody and arrests are still being made," he said.

Yildirim vowed to consider enacting a death penalty, which is not included in Turkey's constitution, "to make sure this will not happen again."

He warned any country against supporting Islamic cleric Fethullah Gulen, whose followers are blamed for the coup.

A country that will stand by cleric Gulen won't be a friend of Turkey and will be considered at war with Turkey, he pointed out.

Turkey's acting army chief Gen. Umit Dundar said that 104 coup plotters have been killed and 1,563 soldiers detained.

"We're determined to cleanse the army of a parallel structure," the chief said in a televised speech soon after he was promoted from the rank of 1st Army Commander to replace Gen. Hulusi Akar, who was taken hostage but later rescued in the coup attempt.

"A military unrest has begun outside the chain of command around several cities of Turkey, mainly in Istanbul and Ankara," Dundar said.

"It has been understood that this unrest was an attempt of coup d'etat by a group of soldiers from different ranks who have nested inside the Turkish army," he added, noting that many commanders were taken to an unknown location.

"In Turkey, the coup d'etat era is over in a way that it will not be opened again," he stated.

In remarks delivered early Saturday in Istanbul, Turkish President Recep Tayyip Erdogan vowed to finish the operation against the military plotters, saying "our army is clean and no one can harm it."

Erdogan was on a seaside vacation when the coup attempt unfolded on Friday night, with tanks rolling into the streets of Ankara and Istanbul.

Appearing on television over a mobile phone overnight, Erdogan had urged people to take to streets to defend the government, and large crowds responded to his call.

He denounced the coup attempt as "treachery," saying he was carrying out his functions and would keep on working "to the end."

"What is being perpetrated is a treason and a rebellion. They will pay a heavy price for this act of treason," Erdogan said. "We will not leave our country to occupiers."

He pointed finger at cleric Fethullah Gulen, his arch-enemy whom he has always accused of seeking to overthrow him.

However, Gulen "categorically" denied any involvement in the plot, calling the accusation "insulting." Gulen has been living in self-imposed exile in the United States for years.

Turkish Airlines announced that flights are due to resume as normal at 1100 GMT on Saturday, its chairman told CNN Turk.

The airline had diverted 35 airplanes and canceled 32 flights on Saturday at Istanbul's main airport, Ilker Ayci told the broadcaster.

Turkish maritime authorities have reopened Istanbul's Bosphorus Strait to transiting tankers after shutting it earlier on Saturday for several hours following the attempted coup.

The Bosphorus is one of world's most important chokepoints for the maritime transit of oil with over three percent of global supply - mainly from Russia and the Caspian Sea - passing through the 17-mile waterway that connects the Black Sea to the Mediterranean.

Meanwhile, countries have condemned the attempted coup and stressed support for Ankara.

Morocco said it was deeply concerned over the ongoing political turmoil in Turkey, where a rebel group in the military attempted to launch a coup against the legitimate government.

In an official statement by the Foreign Ministry, Morocco pledged support for Turkey's stability, saying it refuses any recourse to force to change regimes.

Sudan voiced its strong solidarity with the legitimate government in Turkey on Saturday, declaring support for the country to bolster stability, security and development, as well as enhance its international position.

"The Sudanese government and people have followed, with deep concern, the foiled coup attempt on Friday night, July 15, 2016, against the legitimate Turkish government," Sudanese Foreign Ministry said in a statement.

The statement congratulated the Turkish government on its victory over the foiled military coup attempt.

Iran hailed "the resistance of Turkish people against the coup attempt as a victory of democracy."

"The brave support of the Turkish people of democracy and their elected government proved that the coup has no room in the region and is doomed to failure," Iran's Foreign Minister Mohammad Javad Zarif said.

Saudi Arabia welcomed Erdogan's success in standing against the coup attempt, state news agency SPA quoted a foreign ministry official as saying on Saturday.