President Tayyip Erdogan has defied predictions of his political demise with a strong showing in Turkish elections, weathering his toughest test yet at the polls by mobilising conservative voters who could now propel him to a third decade in power.
Though Erdogan has yet to clinch victory - he must first win a May 28 runoff against his challenger Kemal Kilicdaroglu - he appeared in a celebratory mood as the results came in and supporters of his Islamist-rooted AK Party rallied in Ankara.
"This is a meeting of lovers. We are experiencing the result of this marathon with you tonight," Erdogan, 69, told thousands of flag-waving supporters from the balcony of his party's headquarters.
Victory would entrench the rule of a leader who has transformed Turkey, reshaping the secular state founded 100 years ago to fit his pious vision while consolidating power in his hands in what critics see as a march to autocracy.
While defending himself as a protector of Turkish democracy, Erdogan has amassed power around an executive presidency, muzzled dissent, jailed critics and opponents and seized control of the media, judiciary and the economy. He crammed most public institutions with loyalists and hollowed critical state organs.
On the global stage, he has pivoted the NATO member away from its traditional Western allies, forged ties with Russian President Vladimir Putin, and turned Turkey into an assertive regional power.
Erdogan, the son of a sea captain, had faced political headwinds ahead of Sunday's vote: he was already facing blame over an economic crisis when a devastating earthquake hit in February. Critics accused his government of a slow response and lax enforcement of building rules, failures they said could have cost lives.
Officials said Erdogan had considered delaying the elections after the disaster but changed his mind, confident he could rally voters with pledges to rebuild quickly.
Opinion polls had shown him trailing Kilicdaroglu, nominated by an alliance of six parties for an election they saw as the best chance yet of unseating Erdogan and reversing his course.
But Erdogan, a veteran of a dozen election victories, emerged comfortably ahead of Kilicdaroglu, though just short of the majority needed to win. His AK Party and its allies won a parliamentary majority in Sunday's election.
The outcome reflects the strong support Erdogan still commands, especially in religiously conservative regions where voters long felt marginalised by a once-dominant secular elite.
RALLYING THE BASE
Helped by a largely supportive Turkish media, his campaign has sought to focus attention on economic successes rather than a cost-of-living crisis and the aftermath of the earthquake in which over 50,000 people died.
The month ahead of the vote was peppered with celebrations of industrial milestones, including the launch of Turkey's first electric car and the inauguration of its first amphibious assault ship, built in Istanbul to carry Turkish-made drones.
Erdogan also flicked the switch on Turkey's first delivery of natural gas from a Black Sea reserve, promising households free supplies, and inaugurated its first nuclear power station in a ceremony attended virtually by Putin.
His attacks against Kilicdaroglu have included accusations, without evidence, of him winning support from the outlawed Kurdistan Workers Party (PKK), which has waged an insurgency since the 1980s in which more than 40,000 people have been killed. Kilicdaroglu has denied the accusations.
Over two decades, Erdogan has redrawn Turkey's domestic, economic, security and foreign policy, rivalling historic leader Mustafa Kemal Ataturk who founded modern Turkey a century ago.
He survived an attempted military coup in 2016 when rogue soldiers attacked parliament and killed 250 people.
The economy was one of Erdogan's main strengths in the first decade of his rule, when Turkey enjoyed a protracted boom with new roads, hospitals and schools and rising living standards for its 85 million people.
But it became a political problem as the government embarked on a policy of slashing interest rates in the face of soaring inflation. Aimed at boosting growth, the policy crashed the currency in late 2021 and worsened inflation.
ISTANBUL MAYOR
Erdogan grew up in a poor district of Istanbul and attended Islamic vocational school, entering politics as a local party youth branch leader and becoming Istanbul major in 1994.
He served jail time in 1999 over a poem he recited in 1997 comparing mosques to barracks, minarets to bayonets and the faithful to an army.
After taking to the national stage as head of the AK Party, he became prime minister in 2003.
His government tamed Turkey's military, which had toppled four governments since 1960, and in 2005 began talks to secure a decades-long ambition to join the European Union - a process that later came to a grinding halt.
Western allies initially saw Erdogan's Turkey as a vibrant mix of Islam and democracy that could be a model for Middle East states struggling to shake off autocracy and stagnation.
But his drive for greater powers polarised Turks and alarmed international partners. Fervent supporters saw it as just reward for a leader who put Islamic teachings at the core of public life in a country with a strong secularist traditions, and championed the pious working classes.
Opponents portrayed it as a lurch into authoritarianism.
After the 2016 coup attempt authorities launched a massive crackdown, jailing more than 77,000 people pending trial and dismissing or suspending 150,000 from state jobs. Rights groups say Turkey became the world's biggest jailer of journalists for a time.
Erdogan's government said the purge was justified by threats from coup supporters, as well as Islamic State and the PKK.
At home, a sprawling new presidential palace complex on the edge of Ankara became a striking sign of his new powers, while abroad Turkey became increasingly assertive, intervening in Syria, Iraq and Libya and often deploying Turkish-made military drones with decisive force.
(Additional reporting by Jonathan Spicer and Ali Kucukgocmen; Writing by Tom Perry; Editing by Jonathan Spicer, Samia Nakhoul and Gareth Jones)