ISTANBUL — President Recep Tayyip Erdogan of Turkey accused Iran last month of trying to “dominate the region” through its proxies in Iraq, Lebanon, Syria and Yemen, suggesting to some that Turkey was shifting toward confrontation with its neighbor and joining a Saudi-led coalition to push back against Iranian influence across the Middle East.
Yet it was all smiles and handshakes in Tehran on Tuesday, as Mr. Erdogan was welcomed by Iran’s president, Hassan Rouhani, at the start of a one-day visit that had been long planned but was put in jeopardy after some Iranian lawmakers called for it to be canceled after Mr. Erdogan’s comments.
That the visit went forward suggested that Mr. Erdogan was determined to dial back his harsh language toward Iran and deepen economic ties with its neighbor. The trip also indicated that while Turkey shares the concerns of Saudi Arabia and its Sunni allies about Iran’s growing influence in the region, it will not be a full participant in any effort to contain Iran.
In a joint news conference broadcast live on state television, Mr. Erdogan and Mr. Rouhani pledged to work together to calm regional crises. “The region is burning in a fire,” Mr. Erdogan said. “So far, more than 300,000 were killed in Syria. All were Muslim. We do not know who is killing whom. We have to get united and block the killing and bloodshed.”
The Iranian president called for an end to the Saudi-led airstrike campaign in Yemen — Tuesday was its 13th day — and for all Middle Eastern countries to “fight terrorism and extremism” together.
“We share the idea that instability and war must be ended in the whole region,” Mr. Rouhani added.
Amid the vows of solidarity on Tuesday, Erdem Aydin, an expert on Turkey’s relationship with Iran and a journalist at CNN Turk, called Mr. Erdogan’s recent comments toward Iran “very unusual” and “almost unprecedented” for a Turkish leader.
Mr. Erdogan, like other Sunni leaders in the region, has raised concerns that Iran’s support of Shiite militant groups in Iraq and Syria, which are fighting against the Sunni militants of the Islamic State, and in Yemen is inflaming sectarian tensions in the Middle East.
“I don’t care about Shia or Sunni,” said Mr. Erdogan, who also used the occasion on Tuesday to promote tourism between the two countries. “I care about the Muslim.”
Mr. Erdogan lashed out against Iran in late March after Saudi Arabia, Iran’s main rival in the region, began its military campaign in Yemen against the Houthi movement, a largely Shiite militant group that is supported — but not controlled — by Iran, the region’s pre-eminent Shiite power. In criticizing Iran for its role in Yemen, Mr. Erdogan also said Turkey was willing to provide logistical support to the Saudi-led campaign there.
Experts say Mr. Erdogan’s aggressive posture toward Iran was part of an effort to patch up relations with Saudi Arabia under its new ruler, King Salman, which had become frayed in recent years as Turkey supported branches of the Islamist Muslim Brotherhood around the region and the Saudis cracked down on the group.
Under its new king, Saudi Arabia has relaxed its opposition to the Muslim Brotherhood, which the Saudi monarchy had long opposed as a threat to its rule. King Salman has signaled that he would moderate the Saudi position toward the group, helping to create an opening for greater cooperation between Saudi Arabia and Turkey, which has been among the Brotherhood’s most important supporters in the region.
Mr. Erdogan visited Saudi Arabia last month, and his offer of support to the military campaign against the Houthis “is yet another sign that Erdogan is intent on making amends with the Saudi regime,” said Sinan Ulgen, a former Turkish diplomat and the chairman of the Center for Economics and Foreign Policy Studies, a research organization in Istanbul.
Mr. Ulgen added that Mr. Erdogan had “decided to use Iran, and criticism of Iran, to mend relations with Saudi Arabia.”
Mr. Erdogan’s visit on Tuesday, then, was seen as an effort to reassure Iran that Turkey would not swing fully to the side of Saudi Arabia, and would remain deeply engaged with Iran. On Tuesday morning, the newspaper Daily Sabah, whose views are seen as mirroring those of Turkey’s leadership, wrote in an editorial, “Iran remains one of the few stable countries in the Middle East and, by extension, a valuable partner for regional powers seeking to restore peace and stability.”
That Mr. Erdogan’s long-scheduled visit to Tehran came just after a tentative deal was reached between Western powers and Tehran over Iran’s nuclear program lent the trip another measure of significance. Much of the Sunni Arab world, especially Saudi Arabia, has fretted over the deal, worrying that it would legitimize Iran on the global stage and perhaps embolden Iran’s expansionism across the region. But Turkey, another Sunni power, has largely supported the nuclear deal.
“Turkey has always been on a different wavelength compared to other Sunni countries regarding the nuclear issue with Iran,” Mr. Ulgen said.
Turkey, which relies on Iran for natural gas and has a booming trade relationship with its neighbor, sees itself as well positioned to benefit economically should a final nuclear deal be reached and sanctions on Iran lifted.
“This is a pleasant development for us — for our exporters, investors, businessmen,” Ibrahim Kalin, Mr. Erdogan’s spokesman, said this week, about the nuclear deal. “We surely want to seize the opportunity in this.”
Business ties between the two countries remain close, and few businesspeople expect politics to upend that.
“We concentrate on business and think of nothing else,” said Riza Eser, the head of the Turkish-Iranian Business Council. “Some Iranian officials reacted to what our president said, but our ties are so grounded and strong that it will not have any negative impacts.”
Turkey and Iran have been historical rivals, stretching back to the time when the Ottoman and Persian empires fought several wars in the 15th and 16th centuries. But their shared border has been one of the longest-standing frontiers in the world, essentially unchanged by war since 1639.
Since then the two countries have had an unusual relationship by Middle East standards: rivals and opponents on a number of fronts, but close collaborators on others, and always maintaining a degree of dialogue. The sort of aggressive speech that often typifies the dealings between Middle East rivals has largely been absent from the Turkish-Iranian relationship.
The Syrian civil war provides perhaps the best example of this. The two countries have long been on opposing sides, with Turkey supporting the Sunni rebels opposing the government of President Bashar al-Assad, and Iran, with its proxy in Lebanon, Hezbollah, working to keep Mr. Assad in power. Yet that never stopped Turkey from helping Iran sidestep sanctions over its nuclear program by using gold to buy Iranian gas.
Still, there is growing disenchantment toward Iran among officials of the governing Justice and Development Party in Turkey, who say Iran’s policies have helped inflame the sectarian wars raging in Syria and Iraq, where Iran has been a supporter of the Shiite-dominated government.
“Iran put Iraq on the brink of war because of its sectarian polices,” said Yasin Aktay, a party official in charge of foreign relations. “It turned a blind eye on Assad’s massacres.”
Yet, as Mr. Aydin said, while “there is regional rivalry on one side, there is also a mutually beneficial economic relationship that can’t be compromised.”