ANKARA (NYTIMES) - President Recep Tayyip Erdogan of Turkey has long cast himself as a champion of the Arab Spring uprisings and the political Islamists who once seemed poised to ride them to power.
Crown Prince Mohammed bin Salman of Saudi Arabia anchors the opposite camp in an ideological battle raging across the Middle East, symbolising the anti-Islamist strongmen who quashed the revolts.
The two leaders, each the head of a major regional power, have until now kept their relations cordial in the interest of stability.
But during the past week, tensions between them have erupted over the disappearance of Mr Jamal Khashoggi, a Saudi dissident and Washington Post columnist who vanished after entering the Saudi Consulate in Istanbul on Oct 2.
Mr Erdogan has repeatedly challenged Saudi Arabia to explain Mr Khashoggi's disappearance, while Turkish officials say they have video and audio evidence proving he was killed and have unleashed a stream of leaks suggesting that the royal court ordered it.
The crown prince and his spokesmen have insisted, without providing evidence, that Mr Khashoggi left the consulate freely, professing that they, too, are worried about him.
The dispute pits two headstrong nationalists - both with ambitions to reshape their region - against each other. They also share an aversion to public criticism and a history of refusing to back down from a fight.
"These are two people who each think he is the most important person in the Muslim world," said Mr Steven Cook, a scholar at the Council on Foreign Relations who studies both countries. "Ego is a factor on both sides."
On Thursday (Oct 11), there were signs that the two leaders were looking for a way out. Mr Erdogan's office announced that he had agreed to a Saudi request to form a joint "working group" that will examine Mr Khashoggi's disappearance.
Certainly, each man has much to lose.
Mr Erdogan is struggling to manage a teetering economy and his entanglement in war-torn Syria. He can ill afford a new battle with a deep-pocketed regional power like Saudi Arabia.
For Crown Prince Mohammed, the affair threatens to severely damage the image of moderate reformer that he has worked for years to cultivate.
Eager to diversify the Saudi economy before it runs out of oil, he has courted Washington, Wall Street, Silicon Valley and Hollywood with promises to open up and modernise the kingdom.
The prince has already endured his share of criticism in the West for leading a devastating war in Yemen, temporarily detaining the prime minister of Lebanon, and locking up hundreds of businessmen in a luxury hotel on suspicion of corruption.
If he is held responsible for Mr Khashoggi's disappearance - and perhaps death - that could strengthen domestic enemies bruised by his swift rise to power.
Internationally, the affair is already undermining his courtship of Western visitors and investors. Several participants said on Thursday that they were dropping out of an investment conference known as "Davos in the Desert" that the prince is hosting this month in Riyadh.
"His credibility in the West and in the US is at stake," said Dr Kristian Coates Ulrichsen, a fellow at the Baker Institute for Public Policy at Rice University. "The credibility gap is going to be huge, and the Saudi boosters in DC are going to find it extremely difficult to portray the image that they were generally quite successful in trying to push."
With lawmakers from both parties in Washington threatening to seek sanctions over the case, Saudi leaders appear surprised by the magnitude of the international reaction.
Crown Prince Mohammed has cancelled or postponed meetings with diplomats and other foreign visitors, and Foreign Minister Adel al-Jubeir has been unusually quiet.
Mr Erdogan, for his part, has almost taunted the crown prince with questions, testing how close he can come to blaming Saudi Arabia for Mr Khashoggi's disappearance without explicitly doing so.
"Is it possible that there is no camera system at a consulate, an embassy?" he said, according to Turkish news reports. "Is it possible there was no camera system in the Saudi Arabian Consulate where this incident happened? I mean, if a bird flies from here, a mosquito flies, those systems would capture it. And they have the most advanced ones."
"It is not possible for us to remain silent about such an incident happening in our country," Mr Erdogan said.
Mr Erdogan's greatest concern is not foreign but domestic: Borrowing taken on during his 15-year drive to build up the Turkish economy has left its corporate sector sagging under the weight of more than US$200 billion (S$275 billion) in foreign debt. That has dragged down the value of Turkish currency, spurring high inflation.
Although Saudi Arabia is hardly Turkey's biggest investor, Turkish officials have boasted that their country did US$8 billion a year in business with the kingdom. Wealthy Saudi holidaymakers are a staple of Istanbul's tourist industry.
"The stakes are very high, and that is why Erdogan will be very restrained," said Mr Ozgur Unluhisarcikli, the Ankara office director of the German Marshall Fund of the United States. "Turkey is going through hard economic times, and Saudi Arabia and the Gulf countries have the ability to tip the balance of Turkey's economy."
Mr Khashoggi's disappearance also threatens something less tangible: The prestige that Mr Erdogan's Turkey has enjoyed around the region as a refuge for Arab politicians and thinkers under pressure from their own governments.
"Because Turkey has become such a haven for Arabs who no longer feel safe in their own countries, there is a lot of reputational damage for Erdogan," said Ms Tamara Cofman Wittes, a scholar at the Brookings Institution and a former State Department official.
Several analysts said they already saw hints that Mr Erdogan might be exploring a face-saving retreat for both sides - for example, by allowing the crown prince to acknowledge Mr Khashoggi's death but pin the blame on some rogue element in his government.
The announcement of the joint working group in the case added to the speculation. But how that cooperation might work, given the Turkish allegations against the Saudis, remains to be seen.
PLAYING DOWN DIFFERENCES
Over the years, Mr Erdogan and Crown Prince Mohammed have worked to suppress their differences.
When the Turkish leader cracked down after a failed military coup two years ago, Saudi Arabia was quick to help him, extraditing a Turkish military attaché suspected of playing a role in the plot.
Mr Erdogan singled out the kingdom for special thanks, and the crown prince reciprocated by joining his father, King Salman, in congratulating Mr Erdogan on his survival.
When Egyptian newspapers recently quoted the crown prince calling Turkey part of an "evil" alliance in the region, he hastened to deny it, issuing a statement that he was criticising the Islamists of the Muslim Brotherhood, not the government of Turkey.
But tensions between them still rose.
Mr Erdogan remains close to the Muslim Brotherhood, which Saudi Arabia considers a national security threat and has branded as a terrorist organisation. Turkey has also remained close to Qatar, another regional friend to the Brotherhood.
As he has consolidated power, Crown Prince Mohammed has become increasingly bold.
At age 33, he has charmed younger Saudis and many in the West by promising to diversify the Saudi economy and weaken the kingdom's religious authorities. He has let women drive and allowed concerts and movie theatres - all novelties for the kingdom.
On a tour of the United States this year, he was welcomed as a statesman. He met President Donald Trump; dined with mogul Rupert Murdoch; had his picture taken with tech giants Mark Zuckerberg, Bill Gates, and Tim Cook; and hung out with the actor known as The Rock.
But many of his actions have backfired.
His military intervention in Yemen has so far produced only a stalemate and humanitarian crisis.
His detention of the prime minister of Lebanon was ultimately ineffectual. And his imprisonment without due process of hundreds of wealthy businessmen, including several of his royal cousins, unnerved many of the investors he had set out to woo.
And now, there are the allegations about Mr Khashoggi.
Ms Wittes said that if the Saudis "are willing to assassinate a journalist on foreign soil because he was mildly critical, these international partners are going to be much less likely to send their students, researchers and experts to the kingdom or to set up long-term partnerships with the kingdom".
Being seen in the eyes of the world as responsible for such a grisly assassination might once have been enough to disqualify a crown prince from succession to the Saudi throne.
But Crown Prince Mohammed, who is known as MBS, appears to have amassed more control than any leader in decades over the sources of hard power in the kingdom - the military, the national guard and the Interior Ministry - as well as the Oil Ministry.
Many analysts say there is almost no one left to challenge him - provided he maintains the goodwill of his elderly father.
"There is no real coalition that can mobilise against MBS," said Dr Ulrichsen. "He seems to be secure in his position. And that seems to be the reason we see such actions."