It's difficult to pinpoint just when the leader once nicknamed "The Sultan" became a figure more akin to the emperor who had no clothes.
For more than a dozen years, Recep Tayyip Erdogan's gilded career had taken him from one electoral triumph to the next, heaping spoils and glory not only on the Islamist-rooted political party he co-founded but on the 61-year-old leader himself.
All that changed Sunday, when voters delivered the electoral equivalent of a stinging slap in the face to the man once considered the most popular politician in the country's modern history.
The voting results deprived Erdogan's Justice and Development Party, or AKP, of the single-party power it had enjoyed since 2002, and derailed his personal vision of transforming the largely ceremonial post of president, which he assumed in August, into an overarching seat of power.
The ballot-box verdict could be read as an affirmation of what had long been buzzed about in Turkey's ancient bazaars and spanking-new skyscrapers: that Ergodan, once seen as a savior, was in danger of becoming a national liability.
Wearied by years of harsh crackdowns and grandiose gestures on Erdogan's part, many Turks came to view him as a leader who burned bridges rather than building them. The aura of fear and reverence dissolved into something unfamiliar and far more subversive: laughter.
It wasn't always like that. Erdogan came of political age as an outsider who mounted courageous challenges to Turkey's often-sinister military-dominated power elite. Jailed for reciting a poem, he dabbled in prison verse. In his early years in power, with his star on the rise, he was a darling of the West, hailed as the moderate face of political Islam.
He empowered an entrepreneurial class of pious Muslims who became an engine of Turkey's eye-catching economic growth. In a diverse and complex society struggling to find a foothold in the modern world, Erdogan preached inclusiveness and backed up his words with actions.
As prime minister, he risked considerable political capital to reach out to the minority Kurds and worked to halt a bloody civil conflict of decades' standing. For a time, he worked assiduously to forge friendly relations with neighbors -- even with Israel, reviled throughout the Muslim world.
On the misty shores of the Bosporus, Turks on Monday offered differing day-after assessments of when and how it went wrong for Erdogan. Some traced the trajectory to the violent crackdown on demonstrations that sprang up in 2013 in Istanbul's Gezi Park -- initially a relatively narrow green-minded protest movement that turned into a broader expression of popular discontent.
"The Gezi movement was important, beginning a discourse of change," said Esra Ozyurek, a scholar of contemporary Turkey at the London School of Economics. As arrests and beatings mounted, Erdogan, who had entered politics as a champion of the oppressed, began to be seen as an oppressor.
Hard on the heels of the Gezi protests came a corruption scandal that spurred Erdogan, then still prime minister, to purge hundreds of supporters of a rival movement led by a onetime ally, exiled cleric Fethullah Gulen, from the police, judiciary and media.
At the same time, it escaped the notice of few that Erdogan appeared bent on supplanting the secular-democratic legacy of Turkey's founding leader, Mustafa Kemal Ataturk. Seeking to symbolically undo one of Ataturk's signature feats, a rendering of Turkish in the Western alphabet, Erdogan last year vowed to impose compulsory lessons in Arabic-alphabet Ottoman script.
Bellicose and retrograde statements became the new norm. A women's job, Erdogan told a female audience, is motherhood. Twitter, he declared, was "evil." To the European Union, when it urged greater media freedom, he replied: "Mind your own business." For the New York Times, which recently wrote a sharply worded editorial about Turkey losing its way, he offered this riposte: "Know your place."
Virulent attacks on journalists and social media became routine as the list of matters over which the president was ridiculed grew longer. There was the opulent 1,150-room presidential palace -- complete with Ottoman-era touches such as a team of food testers to guard against poisoning -- whose $615-million cost Erdogan justified just before the election by saying that his previous residence had suffered from an infestation of cockroaches.
There was the movie-set presidential guard, done up in Turkic warrior costumes from centuries past, and the teenage boy dragged from his classroom to account for a Facebook post. A politician once known for skillful, even spellbinding rhetoric fell back on conspiratorial rants, with the final days of the campaign consumed by his dark mutterings about the seditious tendencies of Armenians and homosexuals.
Such rhetoric went down well with the president's conservative base. But the unhappy state of Turkey's affairs of state was memorably encapsulated last month by author Stephen Kinzer, a long-respected observer of the country.
"Once seen as a skilled modernizer, he now sits in a 1,000-room palace denouncing the European Union, decreeing the arrest of journalists, and ranting against short skirts and birth control," Kinzer wrote of Erdogan in a column in the Boston Globe. Retribution was swift: The author said a high civic honor that was to be bestowed on him by a Turkish city was swiftly rescinded.
Erdogan, who was ubiquitous during the campaign -- in defiance of a constitutional role that is supposed to keep the president aloof from politics -- remained silent for a full 18 hours after it first became clear that the AKP's hopes for a parliamentary majority had gone unrealized. Even then, his first public response was in the form of a written statement, not a personal appearance.
The election results, he said, "do not give the opportunity to any party to form a single-party government" -- implicitly inviting the AKP's rivals to consider forming a coalition.
So far, none has expressed an interest in partnering with the AKP. If a new government cannot be assembled within 45 days, Turkey will likely go to new elections. Shock waves from Sunday's election results, meanwhile, rattled Turkey's financial markets Monday, with the stock market sliding and the lira touching new lows.
The party's titular head, Prime Minister Ahmet Davutoglu, reminded the public that the AKP was still the largest bloc in parliament, after winning about 41% of the vote. "It is the winner; it finished first in these elections," he said.
Some analysts pointed out that it is easy to forget that Erdogan skillfully harnessed powerful political impulses that remain widely felt in Turkey -- and could do so again.
"He is still president for the next four years, and he has considerable authorities, and has by all accounts exploited every one of them," said Francis J. Ricciardone, a former U.S. ambassador to Turkey who is now vice president and director of the Atlantic Council think tank. "He is clearly going to be influential."