With such latent tension in the background, the time would appear not to be ripe for a high-level visit from Turkey to Iran, especially one that emphasizes the friendly and historic ties between the two countries.

Boroujerdi’s comments followed the deadly car bomb explosion in Ankara that killed 29 people. The government blamed the People’s Protection Units, the Syrian Kurdish group — linked to the outlawed Kurdistan Workers Party — that has allied itself with Russia against Sunni fighters in Syria who Tehran claims are supported by Ankara.

For example, Alaeddin Boroujerdi , the chairman of Iran’s parliamentary National Security and Foreign Policy Committee, was quoted Feb. 19 by the state-owned Press TV, warning Turkey that it is “playing with fire in the region by nurturing terrorists and providing them with weapons.”

The Iranian government has generally remained diplomatically restrained against such outbursts from Turkey. It has preferred to leave the job of responding to Turkey to the Iranian media — which has often aired virulent claims that Ankara is aiding al-Qaeda-related terrorists in Syria — and to lawmakers in the Iranian parliament.

Prime Minister Ahmet Davutoglu’s visit to Iran last week came as something of a surprise given the frosty climate between Ankara and Tehran due to serious differences over Syria. It was only a matter of days before the visit that Davutoglu, in an interview with Al Jazeera , had lambasted Iran for its support of the Bashar al-Assad regime.

Davutoglu’s visit, nevertheless, highlighted again an aspect of relations between Ankara and Tehran that goes back to the days of the Iranian Revolution in 1979. Namely, that no matter how tense relations get, greater mutual interests ensure that ties are not disrupted and dialogue is not severed.

Speaking at a press conference in Tehran with Iran’s First Vice President Eshaq Jahangiri, Davutoglu skimmed over differences on Syria. “We may have differences over some issues, but we cannot change our history and geography,” Davutoglu said, adding that Turkey and Iran were complementary pieces of a puzzle.

Underlining the contribution the two countries were in a position to make to overcome sectarian divisions in the region, Davutoglu said it was important for the two countries to develop joint perspectives in this regard. “We cannot leave the fate of our region to external actors who are not from the region,” he said.

Iranian President Hassan Rouhani, who received Davutoglu in Tehran, struck an equally positive tone.

“Iran and Turkey have common objectives and interests and must strengthen the foundations for peace and stability in the region through [improving] bilateral cooperation and focusing on the fight against terrorism as a common enemy,” Rouhani said during his meeting with Davutoglu.

“We believe that regional problems should be settled by regional countries and nations,” he added, echoing Davutoglu’s words.

Apart from the political messages given during Davutoglu’s visit, most analysts say the underlying motive for the visit was economic. Professor Huseyin Bagci, who heads the department of international relations at Ankara’s prestigious Middle East Technical University, believes this is also what gives Iran the upper hand.

“The Iranians are managing Turkey from a position of strength. Turkey needs Iranian support, especially in the economic field after Ankara’s high-cost crises with Russia,” Bagci told Al-Monitor.

Davutoglu’s visit comes at a time when Iran is opening up to the world following its nuclear deal with the West, which has whetted the appetite of Turkish investors and businessmen.

While in Tehran, Davutoglu expressed Turkey’s “delight” that sanctions against Iran had been lifted, saying, “These were the greatest barrier to the volume of trade between the two countries reaching $30 billion.” Tellingly, he recalled that “Turkey has stood by Iran during the most difficult days of the sanctions.”

There is no indication, however, that Turkey is automatically favored over Western investors by Iran due to a sense of “Islamic solidarity.” Many analysts argue that Turkey will have to work hard to gain a piece of the Iranian pie.

Retired Ambassador Suha Umar, who has served in the Middle East, is one such analyst.

“Davutoglu’s visit points to a sense of alarm over being unable to grab a slice of the pie. If you look at the state of recent ties with Iran, it’s not as if Tehran is waiting with anticipation for Turkey to come so that it can be given its share of the pie,” Umar told Al-Monitor.

“This does not mean that the Iranians are displeased with seeing Davutoglu come to their turf,” Umar added, “but the Iranians are known to be traders and are aware that Davutoglu’s visit is an opportunistic one."

Umar also underlined that Iran had pursued a much more sensible foreign policy in recent years than Turkey, overcoming its differences with the United States and also getting Russian backing in the Middle East and consolidating its position in the world.

Asked how Saudi Arabia will view Davutoglu’s visit to Tehran, Umar said, “It will feel cheated.” He pointed out that this visit took place against the backdrop of talk about Ankara’s attempt to establish strategic ties with Riyadh, as well as speculation that the two countries were preparing to jointly intervene in Syria.

Both countries have dispelled the idea of such an intervention. Davutoglu also told Al Jazeera recently that he had no confidence that Arab countries would support Turkey if it was to intervene unilaterally in Syria.

Bagci believes that Davutoglu’s visit to Tehran could also signal an effort by Ankara to steer away from the impression that its regional foreign policy is based on sectarian preferences.

“This could be the start of a U-turn away from Sunni policies toward a correct understanding of the responsibilities of those governing a nation-state,” Bagci said. He indicated, however, that President Recep Tayyip Erdogan was the unpredictable element, adding that a single harsh statement from Erdogan against Iran could undermine Davutoglu’s efforts.