He was seen surrounded by cheering supporters, and said the coup attempt was an "act of treason" and the army must be cleansed in a live TV speech.
Forty-two people died during overnight clashes in the capital, Ankara, most of them civilians, prosecutors said.
Prime Minister Binali Yildirim said the situation was largely under control and 130 people had so far been arrested.
He has ordered the military to shoot down aircraft being used by coup plotters.