Istanbul (AFP) - Recep Tayyip Erdogan, who appears to have survived a bloody attempt to remove him from power, is the most divisive leader in the history of the modern Turkish republic.

Adored by supporters as a transformative figure who modernised Turkey, his foes paint him as an increasingly despotic "Sultan" who ruthlessly shuts down any criticism.

Rising from premier to become the nation's first directly elected president in 2014, Erdogan has dreamed of boosting his hold even further by changing the constitution to give Turkey a US-style executive presidency.

- 'Big master' -

But the dramatic events of Friday night have shaken his grip on power in a way few could have imagined even a day earlier.

With a notoriously fiery temper, Erdogan is known to himself and followers as the "buyuk usta" -- the "big master" -- or simply "the Sultan".

The 61-year-old first came to power as prime minister in 2003, bringing stability after a history of coups and rocky coalitions and dragging the Muslim-majority country out of an economic quagmire.

He succeeded in clipping the wings of the military by purging elements that opposed him -- or so he claimed.

But ordinary Turks became suspicious of moves to "Islamicise" society by restricting alcohol sales, curbing the internet and even trying to ban mixed-sex dorms at state universities.

- 'Heavy price' -

Pushing for Turkey to become a top-ten economy by the republic's 100th anniversary in 2023, he launched a series of breathtakingly ambitious infrastructure projects, including a high-speed rail network and a tunnel under the Bosphorus.

But his vast new $615 million presidential palace with 1,150 rooms has been ridiculed as an absurd, tasteless extravagance -- and a symbol of his creeping authoritarianism.

And his ruling Justice and Development Party (AKP) has long been accused of seeking to impose conservative Islamic values on society -- a possible point of friction with a military that has long seen itself as the guardian of Turkey's secular state.

Story continues

Erdogan has faced a wave of deadly bombings as his government pursues twin military campaigns against Kurdish rebels in the south and the Islamic State group in neighbouring Syria.

But the attempted coup bid by disaffected soldiers -- the biggest challenge to his authoritarian 13-year rule -- came out of the blue.

- Critics muzzled -

After a dramatic night of chaos and bloodshed, during which nearly 200 people lost their lives, Erdogan flew into Istanbul on Saturday, denouncing the coup bid as "treachery" and warning the perpetrators they would "pay a heavy price."

In an ironic turn of events, the strongman who has in the past banned street protests and social media, took to Twitter urging supporters to remain on the streets to help ward off any new threats.

"We should keep on owning the streets tonight no matter at what stage (the coup attempt is) because a new flare-up could take place at any moment," Erdogan said.

Erdogan's authoritarianism has seen critics muzzled, with a string of journalists as well as ordinary citizens ending up in court for insulting or slandering him.

The crackdown has earned fierce international criticism for a man initially hailed in the West for creating a model Muslim democracy on Europe's eastern edge.

- Humble beginnings -

But in recent months, the AKP government has suffered a string of diplomatic crises -- making a previous foreign policy known as "zero problems with neighbours" seem almost laughable.

He faced a previous challenge to his rule in 2013 when protests over plans to redevelop Istanbul's Gezi park snowballed into mass anti-government demonstrations.

He is also known for making sometimes bizarre statements, such as declaring Muslims discovered the Americas before Columbus, that women are not equal to men and even boasting "We will wipe out Twitter".

Erdogan has now spent more than a decade at the top as the most powerful Turkish politician since founding father Ataturk, but his beginnings were humble.

The son of a coastguard officer, he is deeply proud of his roots in a working-class Istanbul suburb.

He has a degree in business administration and once played semi-professional football for an Istanbul club.

Rising to prominence in the Islamist movement, he became mayor of Istanbul in 1994, tackling urban woes such as traffic gridlock and air pollution in the megacity of 15 million.

When his religious party was outlawed, he joined demonstrations and was jailed for four months for inciting religious hatred when he recited an Islamist poem.

In 2001 Erdogan, along with long-time ally Abdullah Gul and others, founded the Islamic-rooted AKP, which had won every election since 2002 until June last year when it lost its majority for the first time.

The party bounced back in a second vote in November, boosting Erdogan's hopes once more to consolidate his power.

"The AKP is my fifth child," says Erdogan, who has two sons and two daughters.