Turkish President, Recep Tayyip Erdogan has flown in to Istanbul, after an army group said it took over the country.
The group had declared that a “peace council” now ran the country and there was a curfew and martial law.
Erdogan was seen surrounded by cheering supporters, saying in a live TV speech that the coup attempt was an “act of treason” and the army must be cleansed.
More than 160 people are dead, 1,440 are wounded and some 2,800 soldiers are under arrest.
Prime Minister, Binali Yildirim said the situation was largely under control.
He has ordered the military to shoot down aircraft being used by coup plotters.
Earlier, one of the helicopters being flown by forces involved in the coup attempt was shot down over the capital Ankara.
In a statement, the Turkish foreign ministry said the coup attempt “was foiled by the Turkish people in unity and solidarity. Our president and government are in charge”.
“Turkish Armed Forces was not involved in the coup attempt in its entirety. It was conducted by a clique within the armed forces and received a well-deserved response from our nation.”
Meanwhile, the whereabouts of the military chief of staff, Hulusi Akar, are still unknown as he is reported to have been taken hostage by rebel soldiers, but another Army General, Umit Dundar, commander of the 1st Army, has been appointed acting chief of staff.
Reports also say rebel soldiers in some areas have been surrendering their weapons to police loyal to Mr Erdogan.
The surrender of one unit of 60 soldiers, who had taken control of one of the Bosphorus bridges in Istanbul, was shown live on TV on Saturday morning.
Istanbul’s main Ataturk airport is now under army control, and flights which had been interrupted for some hours were due to resume.