“Turkey had been going through a deep sense of isolation for the past few years, having switched from its famous ‘zero problems with neighbors’ policy to a place where they had no neighbors without problems,” said Asli Aydintasbas, an expert at the European Council on Foreign Relations. “This was the loneliest point in the history of the republic — Qatar and Saudi Arabia looking like the government’s only real friends.”

Under Mr. Erdogan, Turkey has tried to establish friendships with its Muslim neighbors, a shift from the past. But some experts argue that Turkey miscalculated, especially in Syria, where, until recently, it pushed for the ouster of President Bashar al-Assad. It has also opposed the United States there over Kurdish rebels fighting the Islamic State, and has been criticized for letting fighters pass freely across its border with Syria.

In the case of Russia, economics trumped political posturing, Ms. Aydintasbas said. Trade between the two countries had been substantially in Russia’s favor, largely because it sells considerable amounts of oil and gas to Turkey. But Turkey also benefited: More than three million Russians visit each year, the second-largest group of foreign travelers after Germans, and their absence has taken a painful toll on Turkey’s tourism industry.

In his letter to Mr. Putin, Mr. Erdogan said he “would like to inform the family of the deceased Russian pilot that I share their pain and to offer my condolences to them,” according to a statement from Turkey’s presidential spokesman, Ibrahim Kalin.

The effort to repair relations with Russia began the same day that Turkey and Israel announced an agreement to resume full diplomatic relations, ending a bitter six-year rift between the once-close regional allies. The two countries had fallen out over a 2010 Israeli military raid on a Turkish boat, the Mavi Marmara, which was bringing aid to Gaza. Ten Turkish activists were killed.