Recep Tayyip Erdogan has won the presidential run-off election, with leaders from around the world congratulating him.
With 99% of the votes counted, Mr Erdogan, who served as prime minister from 2003 to 2014, won with a share of 52.1%.
It means he has secured a record-breaking third term as president and will serve at least five more years in power.
Turkey election latest
Erdogan thanks crowds as election officials declare him winner
Polls closed at 5pm local time (3pm BST) and while votes were counted fast, for hours it remained too close to call. At one point, less than a percentage point separated the incumbent from his rival, Kemal Kilicdaroglu.
Shortly after 8pm local time (6pm BST) Mr Erdogan stepped out of his home and thanked people for “giving us the responsibility to rule for the next five years”.
He has been congratulated by a host of world leaders. Among them, Vladimir Putin, who wrote a lengthy message to Mr Erdogan, which concluded: “From the bottom of my heart I wish you new successes in such a responsible activity as the head of state, as well as good health and well-being.”
French President Emmanuel Macron also sent well-wishes, as well as reiterating the “immense challenges” both countries face.
“The return of peace to Europe, the future of our Euro-Atlantic Alliance, the Mediterranean Sea,” he tweeted.
“With President Erdogan, whom I congratulate on his re-election, we will continue to move forward.”
Opponent refuses to admit defeat
Kemal Kilicdaroglu took the stage earlier this evening, and in a rousing speech, he refused to admit defeat.
“I wasn’t able to defend your rights,” Kilicdaroglu began by saying. “I did not shirk against an unjust structure, I could not be a silent devil and I was not.
“I could not stand quiet against millions of people becoming second-class citizens in this country.
“I could not let them stand all over your rights. For your children to go to bed hungry. For farmers to not to be able to produce. I could not allow these things.”
He concluded by thanking the 25 million people who voted for him – and says the “battle continues”.
First presidential run-off in Turkey’s history
The pair were forced to go head to head when neither reached the required 50% of the vote in the first round on 14 May and Mr Erdogan’s win will have profound consequences for Turkey, and the wider world.
The two candidates offered sharply different visions of the country’s future and its recent past.
Mr Erdogan’s government vetoed Sweden’s bid to join NATO and purchased Russian missile-defense systems, which prompted the United States to oust Turkey from a US-led fighter-jet project. But it also helped broker a crucial deal that allowed Ukrainian grain shipments and averted a global food crisis.
Meanwhile, Mr Erdogan’s 74-year-old challenger promised to restore a more democratic society.