ISTANBUL • Turkish President Recep Tayyip Erdogan has, in his political career, overcome a stint in prison, mass protests and even a bloody coup attempt to emerge as Turkey's uncontested leader, first as premier from 2003 and then as president from 2014.
He cemented his control in elections on Sunday, and aims to establish himself alongside founder of the republic Mustafa Kemal Ataturk as the leading figures of modern Turkish history.
Born in the working-class Istanbul harbour district of Kasimpasa but brought up near the Black Sea, Mr Erdogan, 64, gained prominence in the nascent Islamic political movements that were challenging secular domination, becoming a popular mayor of Istanbul in 1994.
His term was cut short when he was convicted and jailed for four months for inciting religious hatred when he recited an Islamist poem. But this only magnified his profile.
He founded the AK Party in 2001 after the previous Islamic party led by his mentor Necmettin Erbakan was banned. Mr Erdogan spearheaded the party's 2002 landslide election victory and became premier less than six months later.
His signature early achievements included a series of reforms such as abolishing the death penalty and beginning a peace process with Kurdish militants.
But mass protests in 2013 over plans to turn an Istanbul park into a shopping mall marked the start of a more divisive era as Mr Erdogan came out fighting, dismissing the protesters as "hooligans".
Tensions escalated later that year when a graft scandal broke, implicating Mr Erdogan's inner circle.
In July 2016, a renegade army faction launched a coup bid that the government blamed on influential Islamic preacher Fethullah Gulen. A former AK Party ally, Mr Gulen moved to permanent exile in the United States in 1999, amid accusations that he was trying to overthrow the secular government.
President Erdogan, on holiday in the Aegean then, appeared on the FaceTime app on live TV to urge supporters out onto the streets, before returning in triumph to Istanbul.
The coup bid marked a watershed moment in his rule, with some 77,000 people arrested in the unprecedented purge that followed, further increasing tensions with the West. The country's accession process to join the European Union ground to a halt, with Mr Erdogan complaining that Ankara was being "kept waiting at the door".
To his inner circle, Mr Erdogan is known as beyefendi (sir) and as reis (chief) to admirers.
For him, family is key. One of his closest confidants is Energy Minister Berat Albayrak, the husband of his eldest daughter Esra.
Mr Erdogan's younger daughter Sumeyye plays a key role in a women's non-profit organisation while his two sons are less prominent.