Turkey's president, Recep Tayyip Erdogan, rose to power riding on brash populism.
A former professional soccer player and ex-mayor of Istanbul, he engineered electoral landslides for a party whose pious Muslim base flouted the old secular establishment. In office for more than a decade, he has been increasingly accused of autocratic tendencies.
The failed coup attempt against him appears to have only invigorated his leadership, at least in the short term.
Erdogan suffered setbacks in the past. He was forced out of his Istanbul mayor's post and spent four months in jail in 1999 for reading an Islamic poem that angered the staunchly secular courts of the time. But that experience only seemed to burnish his credentials as a man of the people.
He became prime minister in 2003, championing the idea of Turkey as a role model for democratic rule in Muslim countries and spurring its bid to join the European Union, a campaign that has since foundered.
Over time, though, some Turks became increasingly concerned about alleged efforts by Erdogan to impose Islam on Turkish life and crackdowns on perceived opponents that raised worries about human rights backsliding and infringements on free expression.
While the coup attempt was underway, Erdogan broadcast a message of defiance from the FaceTime app on an iPhone — a tactic that later drew bemused commentary from Turks who recalled past government efforts to restrict YouTube and other social media platforms.
These days, Erdogan's critics draw comparisons with the strongman tactics of Russian President Vladimir Putin or Hugo Chavez, the Venezuelan leader who died in 2013. Notably, a 2002 coup briefly removed Chavez but in the end only made him stronger when he returned to power, in part because it discredited his foes.
For the moment, Erdogan is riding high on public outrage over the coup attempt. He has vowed that its plotters will pay a heavy price, raising the possibility of military purges.
"He comes out of this tremendously strengthened," said Howard Eissenstat, associate professor of Middle East history at St. Lawrence University in Canton, New York.
"This has remobilized a base that was getting sort of tired of him. It gave him at least a moment in which he unified all elements of society against a clear threat," Eissenstat said.
Turkey has long been guided by strongman cults. There were centuries of Ottoman imperial rulers; then Mustafa Kemal Ataturk, the national founder who imposed an unrelenting vision of secularism that benefited like-minded elites; and the military, quick to stage coups in the past when unhappy with civilian leadership.
On Erdogan's early watch, the economy grew and diplomats confidently fanned out across the region. But the early successes have faded somewhat as fallout from regional conflicts, including the arrival of several million refugees fleeing war in Syria, and a breakdown in peace talks with Kurdish rebels weighed on Turkey's fortunes.
Erdogan, who switched from prime minister to president in 2014, has pushed for constitutional changes that would give him more power. His supporters have linked his legacy to plans for the centenary of Turkey's national founding in 2023, suggesting he has ambitions to stay in power at least until then.