ISTANBUL — WHEN Turkey invaded Iraq recently to oust Kurdish rebels, the US backed the move. But with the US turning the heat up on Iran, Turkey has become a cool ally for Washington.
The recent decision by the Clinton administration to impose unilateral economic sanctions on Iran has created an embarrassing situation for Ankara. Turkey, however, is asserting its own policy, with priority on its national interests, at the risk of causing a little ill will with Western allies, say diplomats here.
''On the one hand, we have a deep friendship and working relationship with the US,'' Prime Minister Tansu Ciller recently told reporters here. ''On the other hand, Iran is a neighbor country with which we have historic ties. We must maintain the dialogue with both sides.''
But Turks share some of Americans' concerns about Iran, while at the same time recognizing that Turkey's strategic and economic interests do not permit it to embrace the United States ''dual containment'' campaign against Iran and Iraq.
Turkey, too, is concerned with Iran's efforts to promote fundamentalism in Turkey, as well as other Islamic countries. Turkish intelligence sources say they have found substantial proof of ''Iranian connections'' with local Islamist radical groups that promote violence.
And Tehran's criticism of Turkey's secularism has angered officials here. Iran's state-owned press regularly condemns the secular reforms begun by Mustafa Kemal Ataturk, the founder of modern Turkey. And on a recent visit to Ankara, the Iranian foreign minister refused to visit Ataturk's mausoleum, causing further displeasure in official circles here.
In addition to these deep differences over political systems, Turkey and Iran are engaged in a race for influence in Central Asia. Iranians are trying to gain support for Islamism by distributing hundreds of thousands of copies of the Koran, building mosques, and sponsoring student scholarships. The Turks are exploiting their Turkic ethnic bonds with those new republics by propagating the Turkish language and sponsoring educational programs.
Both countries are vying for lucrative oil contracts in the Central Asian republics: Turkey wants oil from Azerbaijan to flow through a pipeline routed through southern Turkey, while Iran is campaigning for its own route.
The US view that Iran is promoting terrorism and building up a dangerous military and nuclear capability, also has support in Turkey's foreign and defense ministries. But all these considerations are pushed back, because of Turkey's other vital interests with Iran.
Trade -- including Turkey's imports of Iranian oil and border trade -- are considered extremely important. A day after the US announced economic sanctions against Iran, Turkey and Iran signed a $20 billion agreement that provides a supply of natural gas to Turkey for 23 years.
Turkish politicians from all parties as well as noted commentators pressed Mrs. Ciller's government to avoid the same mistake it made in Iraq, where solidarity with the West in applying economic sanctions has caused Turkey to lose about $20 billion in revenues since 1991.
''The international embargo on Iraq has not brought down Saddam,'' says a senior Turkish foreign ministry official. ''It is doubtful that a partial embargo on Iran will make any difference.... What we fear is that it ... may even lead to the creation of camps, with the US and the Russian Federation adopting opposing positions, and even to divisions between Western countries.''
Moreover, the popular daily Hurriyet noted that ''Turkey has also vital strategic interests with Iran, namely in fighting Kurdish nationalism and the terrorist group PKK [Kurdish Workers' Party].''
Iran has pledged to support Turkey by blocking the PKK from setting up bases on its soil.
The Turkish government has kept its promise to pull back its troops from northern Iraq, six weeks after 35,000 troops marched 25 miles deep into the country to wipe out PKK bases there.
But the Turkish military action provoked sharp reaction in the West, particularly after some government officials suggested that Turkey wanted to maintain a military presence there.
Turkey withdrew most of its troops by May 2, but about 1,000 military personnel are expected to remain in the area, where they are said to be monitoring the activities of the PKK.
The European Union had strongly criticized Turkey's military advance into northern Iraq, and hinted approval of a customs-union agreement with Turkey may not pass a parliamentary vote. But since Turkey withdrew, EU criticism has subsided.
But when she was in Washington in April, Ciller made it clear that if the PKK returned to northern Iraq, Turkish troops would strike back.
''Turkey will not hesitate to take such action to protect its security, whatever the world may think about it,'' she said.