They were once seen as bitter foes, but friendship with Syria and Iran has become a staple of Turkey's foreign policy in recent years.

Now, however, that approach -- a vital plank of Turkish Foreign Minister Ahmet Davutoglu's "zero problems with neighbors" philosophy -- is under threat, courtesy of Syria's brutal crackdown on antigovernment demonstrators that has killed an estimated 2,000 people in recent months.

Just how far things have deteriorated was demonstrated on August 9, when Davutoglu traveled to Damascus to read the riot act to the Syrian president, Bashar al-Assad, in whom the Turks have previously invested much time in cultivating better ties.

Davutoglu carried the message that Assad had to cease the repression, enact urgent reforms and release political prisoners -- or face the same international abandonment as the Libyan leader, Colonel Muammar Qaddafi.

Returning to Ankara, Davutoglu implicitly acknowledged that Turkey had effectively abandoned Assad and that its sympathies were now with the demonstrations.

Turkish Foreign Minister Ahmet Davutoglu

He said that the situation would "be passing through a critical process" in the coming days and that his country's "main criterion is that the shape of the process must reflect only the will of the Syrian people."

Ankara's decision to confront Assad's use of violence may not be surprising. The Turks after all saw around 10,000 Syrian refugees pour across their frontier in June as residents fled Assad's security forces when they rampaged into towns near the border.

Most striking is its implication for Turkey's hitherto flourishing relationship with Iran, whose theocratic regime has staunchly supported Assad and which is rumored to have assisted his forces to quell the uprising.

Iran has for years been Damascus's closest ally in the Middle East. Both countries are linked by a shared alliance with the Lebanese Shi'ite group, Hizballah, support for the Palestinian militant organization Hamas, and -- of course -- implacable opposition to Israel.

Burgeoning Turkish-Iranian Trade

But in recent years, Tehran has also drawn closer to Turkey, a key Western ally and NATO member. Closer ties have resulted in burgeoning trade between the two and Ankara vocally opposing United Nations sanctions against Iran over its suspected nuclear program.

Davutoglu's less-than-friendly visit to Assad coincided with an open denunciation of Syrian repression by King Abdullah of Saudi Arabia, who warned on August 8 that "either [Syria] chooses wisdom on its own or it will be pulled into the depths of turmoil and loss."

Those comments were interpreted in some quarters as a subtle swipe at Iran, Saudi Arabia's bitter adversary across the Persian Gulf. They were also thought to have been prompted by pressure from the United States.

According to Murat Bilhan, head of International Relations at Kultur University in Istanbul and a former Turkish diplomat in Iran, abandoning Assad means Turkey risks being seen by Iran "as an ally of the West and as some kind of subcontractor of the West in the region."

Davutoglu has been at pains to refute such a charge, saying at a press conference in Ankara that "in no era of the Turkish state's presence, no Turkish government or Turkish Foreign Ministry ever became the subcontractor of any state, or will ever become one."

Iranian state media have been openly critical of Turkey's anti-Assad policy. On June 9, for instance, the website of the English-language Iranian satellite channel, Press TV, carried a report blaming the unrest in Syria on "deal-making" by Turkey's Prime Minister Recep Tayyip Erdogan.

The insideIRAN.org website described how Iranian government-linked sites carried pieces asking whether "Iran will choose between its strongest ally, Syria, or its trade partner, Turkey."

Concerns over relations with Iran prompted Davutoglu to visit Tehran in early July, when according to a Turkish Foreign Ministry insider, he attempted to bring Iranian officials round to Ankara's viewpoint.

"There are differences [between us] over Syria because we think the protests are popular movements whereas they [the Iranians] think they are instigated from abroad," the insider, who spoke on condition of anonymity, told RFE/RL. "The people in Iran are aware that reforms have to happen but they want Assad to remain in power. We told them that we are not against Assad's regime but that there should be some more openness and changes introduced, so our differences are nuanced.

"The minister [Davutoglu] emphasized that there should be no foreign interference in Syria but that this should apply to Iran too. They [the Iranians] are claiming there should be no foreign interference from any outside power and we are saying that should include Iran."

Turkish officials say criticism from Iran over Turkey's position has abated since Davutoglu's Tehran visit.

Relations Colder, But Not Severed

Indeed, some analysts believe Iran's supreme leader, Ayatollah Ali Khamenei, may decide to abandon Assad if he appears doomed. "Assad is in deep trouble [and] Khamenei will not want to sink alongside Assad," Meir Javedanfar, an Iranian-born commentator with the Israel-based think tank MEEPAS wrote in an e-mail.

"The second he realizes that Assad's ship is sinking, and that the situation can't be salvaged, he'd abandon him -- maybe not publicly, but privately. In fact it would be safe to assume that the Iranians are already privately asking Assad to introduce major reforms. They may even be talking to some elements within the Syrian opposition."

Murat Bilhan believes relations between Turkey and Iran -- though definitely colder -- are not at an end.

"I don't think Turkey has lost Iran," he says. "Iran may not be lost but Iran may be a little distant -- more distant than before and they would not trust. But, if and when Turkish and Iranian interests converge, say for instance in fighting against separatism or something, then they would cooperate."