The killing of Saudi Arabian journalist and columnist Jamal Khashoggi in 2018 by Saudi agents in Istanbul sent an already tense and shaky relationship between Turkey and Saudi Arabia into complete free fall.
Fast-forward 3½ years later and it appears Turkey and Saudi Arabia are attempting to build a bridge and move on.
In his first trip to Saudi Arabia in five years, Turkish President Recep Tayyip Erdogan embraced Crown Prince Mohammed bin Salman and sipped traditional Arabic coffee with King Salman before a state dinner and direct talks that ran into the early hours of Friday.
Here's a look at what's underpinning rapprochement between the two Sunni Muslim powerhouses:
What's behind Turkey's diplomatic pivot?
Turkey's diplomatic drive coincides with the country's worst economic crisis in two decades. Having wealthy Gulf Arab states as allies can help draw investments. Turkey has also taken steps to improve relations with Egypt and Israel.
After mending ties with the United Arab Emirates, Abu Dhabi announced a $10 billion fund to support investments in Turkey and made other moves to support the economy.
Official inflation stands at a staggering 61% while the lira tumbled 44% in value against the dollar last year. These figures do not bode well for Erdogan, whose grip on power could be threatened by the country's economic woes. Turkey is scheduled to hold elections next year.
Meanwhile, Saudi Arabia is enjoying a bumper economic year with its foreign reserves expected to climb. Higher energy prices are forecast to rake in more than $400 billion of revenue this year for the kingdom. In other words, Saudi Arabia has capital to invest in Turkey.
What's in it for Saudi Arabia?
Saudi Arabia's change of heart comes as the kingdom seeks to broaden its alliances at a time when relations between Riyadh and Washington are strained.
The crown prince has yet to hold a direct call with President Joe Biden since he took office over a year ago. A number of lawmakers from Biden's Democratic Party have openly called on him to get even tougher with Saudi Arabia, calling the kingdom a bad strategic partner as it sticks to an OPEC-led pact with Russia that critics say has worsened an oil supply crunch amid the war in Ukraine.
The timing for reconciliation also makes more sense now. Saudi Arabia ended a years-long embargo on Qatar over its support for the Muslim Brotherhood and Islamist opposition groups. Although relations have been restored between Saudi Arabia and Qatar, they had yet to be fixed with Qatar's steadfast ally — Turkey— until now.
Possibly, the strongest impetus for reconciliation is that the crown prince wants to put a definitive end to the scandal of Khashoggi's killing that has loomed over him and cast a pall on his reputation.
Big name Western investors and politicians stayed away from Riyadh in the aftermath of the killing, though some have since returned to do business again in the kingdom.
Khashoggi had been writing columns in The Washington Post hailing the crown prince's social reforms while expressing concern over far-reaching arrests of perceived critics. The billionaire owner of the Post, Jeff Bezos, subsequently commissioned an investigation that concluded his phone was hacked after receiving a message from the crown prince, though many questions remain unanswered.
How was Turkey pressuring the crown prince?
Turkish authorities fanned the global outrage and suspicion directed at the crown prince. Turkey shared audio of the gruesome slaying with Western intelligence agencies, a signal the Saudi consulate where he was killed had been bugged. U.S. intelligence subsequently concluded the operation could not have happened without the prince's go-ahead. Crown Prince Mohammed has denied any involvement.
While never naming Crown Prince Mohammed, Erdogan said the operation that killed Khashoggi was ordered by the "highest levels" of the Saudi government. Khashoggi had entered the consulate in October 2018 by appointment to obtain papers to allow him to wed his Turkish fiancée, who waited for him outside. He never emerged and his body was never found.
Turkey had a case open against 26 Saudi suspects in absentia, but three weeks to the day before Erdogan was set to land in Saudi Arabia, the Turkish prosecutor pulled the plug on the case by transferring it to the kingdom, which had already held its own widely criticized trial. No officials overseeing the operation were ever convicted.
What happened when ties were strained?
Saudi Arabia launched an unofficial embargo on Turkish exports, dramatically curbing around $5 billion in bilateral trade. The kingdom also temporarily barred wildly popular Turkish soap operas that were dubbed into Arabic from airing on affiliated satellite television stations. Those soap operas had helped boost Turkey's cultural clout across the Mideast and drew tourism and investment to Turkey from viewers.
Before Khashoggi's slaying, Saudi investments had reached around $2 billion and Turkey's investments in Saudi Arabia were valued at around $660 million. More than 200 Turkish companies were operating in the country, according to Turkey's foreign ministry. A year before the killing, Saudi citizens had bought up more than 3,500 properties in Turkey.
What are the broader implications now?
Following years of upheaval across the region, the Muslim Brotherhood group has largely been crushed by authoritarian states. Saudi Arabia and the UAE are once again most concerned with Iran, which has been inching toward a nuclear deal with the U.S. that could lift key sanctions.
Turkey and Iran, while not rivals, have competed for power in Syria and Iraq, though they maintain economic relations and share a border. Having Turkey closely aligned with Gulf Arab states could add pressure on Iran.
A detente could also diffuse tensions in Libya, where proxy battles have played out between the UAE and Turkey. It could further usher in a more pragmatic foreign policy approach by Gulf Arab states and help ease the diplomatic isolation Turkey has faced from some Western nations.
Still, mistrust is almost certain to linger below the surface between Crown Prince Mohammed and Erdogan.