President Tayyip Erdogan has developed strong economic and political relations with both Moscow and Kyiv in recent years, which leave Turkey facing a delicate balancing act in its response to the Russian invasion of Ukraine.
Ankara cannot afford to fall out with Russia economically because of tourism revenues, gas supplies, grain and other agricultural trade, and a nuclear power project.
The rival positions Turkey and Russia have taken in wars from the Middle East to the Caucasus mean it must also tread carefully to avoid widening fault lines in their awkward alliance.
Growing tourism, trade and defense ties with Ukraine are also part of the calculations for Erdogan, who has said he backs Ukraine's territorial integrity and is "sincerely saddened" by Russia's invasion.
Ukraine has asked NATO member Turkey to close the Bosphorus and Dardanelles to Russian ships. Under a 1936 pact, Ankara has control over the straits and can limit passage of warships in wartime or if threatened, but says its powers are limited by a clause allowing vessels to return to their bases.
Tourism
Tourism is a significant source of hard currency for the Turkish economy and economic woes driven by a slide in the lira have boosted the significance of that income.
Seven million Russians visited Turkey in 2019, the largest number from any country. The COVID-19 pandemic hit tourism revenues hard, but Russian visitor numbers rebounded to 4.7 million last year.
Ukraine too has become a major source of tourists, with some 2.1 million Ukrainians visiting Turkey last year.
Defense
Turkey purchased Russian S-400 missile defense batteries in 2019 and has suggested it could buy more, despite Washington's resulting move to cancel the sale of US F-35 fighter jets and sanction Turkey's defense industries.
Erdogan said in September Turkey was considering more joint defense industry steps with Russia, including for fighter jets and submarines.
Turkey has also sold sophisticated drones to Ukraine and agreed a deal to co-produce more, angering Moscow.
Energy
Russian natural gas made up 45% of import-dependent Turkey's gas purchases last year, which hit a record level as a result of drought and a related rise in gas-driven power production.
Turkey also imports crude oil from Russia, with annual amounts varying between 10% and one third of its crude imports.
Grains
Turkey depends heavily on the two countries for grain although the agriculture ministry has said it does not expect supply shortages due to the invasion. Russia accounted for 56% of Turkish grain imports in 2021 at $2.24 billion, while imports from Ukraine amounted to $861 million.
Nuclear
Russian nuclear conglomerate Rosatom is building a nuclear plant at Akkuyu in southern Turkey. Erdogan has suggested that Russia collaborate on the construction of two further plants.
Rivalries
Geopolitical rivalries complicate relations. Turkey has deployed troops in northern Syria to push back Russian-backed Syrian government forces, and the two countries backed rival sides in the wars in Libya and Nagorno-Karabakh.
In Syria, Turkey backs fighters who once appeared close to toppling President Bashar al-Assad, until Russian intervention shored up the Syrian leader and helped drive the insurgents back to a small pocket of northwest Syria on the Turkish border.