Turkey and Russia's presidents have agreed to restore friendly ties a mere nine months after the shooting down of a Russian fighter jet over Turkish airspace plunged contacts between the two nations to their lowest ebb since World War II.
"We have decided to bring relations back to the level they should be," said Turkey's President Recep Tayyip Erdogan at the end of talks held on Tuesday amid the splendour of a gold-adorned old Russian imperial residence on the outskirts of St Petersburg. "Our priority is reaching pre-crisis levels of bilateral cooperation," responded Russian President Vladimir Putin.
Although details of the Turkish-Russian agreement remain sparse, senior Western diplomats agree that the rekindling of the so-called "axis of friendship" between the two nations could have far-reaching consequences for security arrangements in the Middle East.
It was Turkey that blinked first in the showdown with Russia. For although the military confrontation that resulted in the downing of the Russian Su-24 fighter jet in November last year came after repeated violations of Turkey's airspace by the Russian military, it was Turkey's economy that suffered most.
Russia is Turkey's second-largest trading partner after Germany, and President Putin's decision to freeze all economic ties in the aftermath of the November incident hurt the Turkish economy very hard. The all-important Turkish tourism industry was devastated by the loss of nearly 3.5 million Russian travellers per year, and bilateral trade between the two countries, which totalled US$25 billion (S$34 billion) last year, was halved.
We have decided to bring relations back to the level they should be.
TURKISH PRESIDENT RECEP TAYYIP ERDOGAN
Our priority is reaching pre-crisis levels of bilateral cooperation.
RUSSIAN PRESIDENT VLADIMIR PUTIN
Further economic losses loomed, such as the possible end of Turkey's dream to become the hub for Russian oil and gas pipelines supplying southern Europe, or the possible end to gigantic Turkish infrastructure projects, such as the Russian plan to construct Turkey's first nuclear power plant.
The famously prickly Mr Erdogan does not like admitting he is ever wrong, and very seldom apologises. But in the case of Russia, the Turkish leader did both: He wrote to and spoke over the phone with Russia's president expressing regret over last November's incident. And at this week's summit he was effusive, addressing Mr Putin as "my dear friend" no less than three times in as many minutes. Necessity is often the mother of all historic reconciliations.
The rapprochement with Russia is made easier by the new political mood in Turkey in the aftermath of last month's failed military coup. Despite strenuous denials from Washington, many ordinary Turks and quite a few officials close to President Erdogan suspect American involvement in the attempt to overthrow their government, largely because the Turkish Muslim cleric Fethullah Gulen, whom they accuse of masterminding the coup, lives in the United States.
Mr Erdogan is also incensed with the response of the Europeans to the attempted coup. "Instead of showing empathy, Western leaders had the opposite reaction," the Turkish leader complained this week in an interview with Le Monde, France's top daily.
The Russians have not offered much empathy either, but at least they have not criticised Turkey's human rights record, and are now providing a useful peg for Mr Erdogan's frustration with the West.
However, Mr Erdogan's biggest objective in improving his country's relations with Russia is to gain some influence over Russian policies in Syria. The Turkish leader is deeply suspicious of Russia's military involvement in the Middle East. In common with its Western allies, Turkey sees the overthrow of Syrian President Bashar al-Assad as as a prerequisite to any solution, and blames Russia for keeping Mr Assad in power.
But the Turks are even more worried today about the danger of Syria's break-up and the rise of a possible separate state for the Kurds on Syria's territory which could act as a magnet for the large number of ethnic Kurds inside Turkey itself.
And the more US Secretary of State John Kerry tries to negotiate a cooperation deal between the Americans and Russians over the future of Syria, the more Mr Erdogan fears that a Kurdish state could be the final outcome or arrangements hatched behind his back.
By getting closer to Mr Putin, Mr Erdogan not only aims to preclude such a scenario, but also hopes to regain for Turkey a key role in the Middle East, a region in which Turkish influence has recently been declining. The result may well be that Turkey drops its demand for the overthrow of Mr Assad in return for Russian support for Syria's territorial integrity, a switch with massive implications for the Middle East.
One thing is, however, beyond doubt - Mr Putin is the biggest beneficiary from the Turkish climbdown.
Characteristically, the Russian leader prefers to remain inscrutable - he did not smile even once during this meeting with the Turkish president.