Tayyip Erdogan secured his place in history as Turkey's first directly elected head of state on Sunday, taking him a step closer to the presidential system he covets in a result his opponents fear heralds an increasingly authoritarian rule.
Supporters honking car horns and waving flags took to the streets in the capital Ankara after results on Turkish television said Erdogan, the prime minister for more than a decade, had won 52 percent of the vote, 13 points more than his closest rival and avoiding the need for a second round runoff.
The chairman of the High Election Board confirmed Erdogan had a majority, with more than 99 percent of votes counted, and said full provisional figures would be announced on Monday.
"Today is a new day, a milestone for Turkey, the birthday of Turkey, of its rebirth from the ashes," Erdogan, 60, told thousands of supporters in a victory speech from the balcony of his ruling AK Party headquarters in Ankara.
"I want to underline that I will be the president of all 77 million people, not only those who voted for me. I will be a president who works for the flag, for the country, for the people," he said, vowing a "period of reconciliation" and chastising those who accuse him of being dictatorial.
Turkey has emerged as a regional economic force under Erdogan, who has ridden a wave of religiously conservative support to transform the secular republic founded by Mustafa Kemal Ataturk on the ruins of the Ottoman empire in 1923.
But his critics warn that a President Erdogan, with his roots in political Islam and intolerance of dissent, would lead the NATO member and European Union candidate further away from Ataturk's secular ideals.
After his victory is officially confirmed, Erdogan will be sworn in as president on Aug. 28. The AK Party was to begin meeting shortly to start deciding on candidates to replace him as premier and party leader. Foreign Minister Ahmet Davutoglu is seen as a leading candidate.
Erdogan's main rival in Sunday's election, Ekmeleddin Ihsanoglu, a former diplomat and academic who won 38.5 percent of the vote according to broadcasters CNN Turk and NTV, congratulated Erdogan on the result in a brief statement.
Selahattin Demirtas took 9.7 percent, according to the TV stations - a result for an ethnic Kurd that would have been unthinkable just a few years ago as Turkey battled a Kurdish rebellion and sought to quell demands from the ethnic minority.
"We will continue to defend our principles and values. The message we wanted to deliver has reached the whole country, to every village, district, town in Turkey," Demirtas told reporters in the mainly Kurdish city of Diyarbakir.
Erdogan's core supporters, religious conservatives, see his victory as the crowning achievement of his drive to reshape Turkey and break the hold of a secular elite.
In a tea house in the working-class Istanbul district of Tophane, men watching election coverage on television praised Erdogan as a pious man of the people who had boosted Turkey's status both economically and on the international stage.
"Erdogan is on the side of the underdog. He is the defender against injustice," said Murat, 42, a jeweller, who declined to give his family name.
"This country was ruined by the old politicians. They lied to us. They caused economic crises, the PKK violence," he said. Erdogan has opened a peace process with Kurdish PKK militants to end a conflict which has killed 40,000 people in 30 years.
The voting turnout, which exceeded 89 percent in March local elections, appeared to be low, OSCE Parliamentary Assembly observer George Tsereteli told reporters.
Opinion polls had put Erdogan far ahead of his two rivals competing for a five-year term as president. Parliament has in the past chosen the head of state but this was changed under a law pushed through by Erdogan's government.
He has set his sights on serving two presidential terms, keeping him in power past 2023, the 100th anniversary of the secular republic. For a leader who refers frequently to Ottoman history in his speeches, the date has special significance.
He had, in campaign speeches, repeatedly vowed that his election would herald a "new Turkey."
But his vision left voters cold at one polling station in the capital Ankara, where many complained of deep polarization under Erdogan and said only his AK Party loyalists had benefited from changes in the past decade.
"The freedom that he says has increased is for his own supporters. You can only be free if you support him. He has polarized this country in a way nobody has before," said Yucel Duranoglu, 45, who works for a private company.
Erdogan has vowed to exercise the full powers granted to him by current laws, unlike predecessors who have played a mainly ceremonial role. But he also plans to change the constitution to establish a fully executive presidency.
The current constitution, written under military rule after a 1980 coup, would enable him to chair cabinet meetings and appoint the premier and members of top judicial bodies including the constitutional court and supreme council of judges.
Erdogan's AK scored a clear victory in local elections in March and Sunday's triumph will emphatically put an end to the toughest year of his time in power.
He was shaken by nationwide anti-government protests last summer, and months later, Erdogan and his inner circle were targeted by a corruption investigation and a power struggle with his former ally, U.S.-based cleric Fethullah Gulen.
He accuses Gulen of seeking to overthrow him and has pledged as president to continue purging institutions such as the police and judiciary where Gulen is believed to wield influence.
Despite the challenges Erdogan has faced, there was an air of resignation among many voters who oppose him.
"I am almost depressed. I worry for my country because I increasingly feel like an alien here. The prime minister is talking about a Turkey that I don't recognize," said Erkan Sonmez, 43, who works in an import-export business.
"I can no longer speak to my neighbors who vote for the AK Party, does that sound like a peaceful community to you?"