Erdogan won 51.8 per cent of the vote, way ahead of his main opposition rival Ekmeleddin Ihsanoglu on 38.6 per cent, according to official results based on a 99 per cent vote count.
The third contender, Kurdish candidate Selahattin Demirtas, won 9.6 per cent of the vote.
Erdogan's inauguration is set for August 28.
The result marked a personal triumph for Erdogan, 60, who has served as premier since 2003 and could potentially now be president for two mandates until 2024.
More From This Section
The polls are the first time Turkey -- a member of NATO and longtime hopeful to join the EU -- has directly elected its president, who was previously chosen by parliament, and Erdogan hoped for a massive show of popular support.
As the results came out, Erdogan briefly addressed hundreds of supporters in Istanbul before praying at the historic Eyup Sultan mosque built after the 1453 conquest of Constantinople by the Ottomans.
"As long as I am alive, I will continue our struggle to sustain a more advanced democracy," said Erdogan before heading to Ankara where he is expected to give a full victory speech.
But Erdogan's opponents accuse him of undermining the secular legacy of Turkey's founding father Mustafa Kemal Ataturk, who established a strict separation between religion and politics when he forged the new state from the ashes of the Ottoman Empire.
"A ballot paper with only one name does not represent the democracy, it does not suit Turkey," said Ihsanoglu, 70, as he cast his ballot in Istanbul.
Erdogan ran a lavish three-month campaign that swamped those of his rivals, his face glaring down at pedestrians in Istanbul from gigantic billboards at almost every street corner.