ISTANBUL -  Diplomatic tensions escalated between Turkey and Iran on Tuesday as the regional powers traded accusations over their roles in the Syria conflict and the Middle East.

The pair have been rivals for centuries but have sought to forge a pragmatic relationship in recent years, with the Islamic Republic strongly supporting Turkish President Recep Tayyip Erdogan after last year's failed coup.

But mainly Sunni Muslim Turkey and Shiite Iran have been on opposite sides of the conflict in Syria, with Ankara seeking the ouster of President Bashar al-Assad and Tehran, along with Russia, his key backer.

The tensions come with UN-backed peace talks for Syria due to restart on Thursday and Turkey engaged in fierce fighting inside Syria to capture the town of Al-Bab from militants.

Foreign Minister Mevlut Cavusoglu lashed out at Iran in a speech to the Munich Security Conference at the weekend, saying some of its actions had undermined security in the region and urging Tehran to promote stability.

"Iran wants to make Syria and Iraq Shiite," he was quoted as saying by Turkish state media.

Erdogan has also in recent weeks accused Iran of promoting a "Persian nationalism" that had damaged the Middle East.

The Iranian foreign ministry on Monday summoned the Turkish envoy to issue a protest after Cavusoglu's comments while spokesman Bahram Ghassemi warned that Tehran's patience "has limits".

"We hope that such statements are not made again. If our Turkish friends continue with this attitude we will not remain silent," he added.

Turkey's foreign ministry spokesman Huseyin Muftuoglu hit back by saying it was "incomprehensible" to receive such accusations from Tehran who he charged with "not hesitating to push into war zones refugees sheltering from regional crises."

"Instead of accusing countries that have criticised Iran, it should take constructive steps and review its own regional policies."

The angry exchanges have come just after Erdogan returned from a week-long tour to the Arabian peninsula, including talks with the leadership of Iran's arch regional foe and Ankara's Sunni ally Saudi Arabia.

Ali Vaez, senior Iran analyst with the International Crisis Group, said Iran and Turkey feared the other was seeking to capture regional hegemony via proxies on the ground.

"With each failure to find an accommodation, the context of Turkey's and Iran's rivalry has become more complex and disagreements more intractable," he told AFP.

While Turkey has backed rebels in Syria throughout the conflict, Tehran has played a crucial role in aiding Assad. Iran has provided few details over its involvement but has confirmed the deaths of some 1,000 volunteer fighters in Syria.

Ankara has meanwhile warned Iran and its allies in the Baghdad government against using Shiite militia in the assault to recapture the militant-held Iraqi city of Mosul.

"It's very dangerous to send Shiite militia into a 99 percent Sunni Arab city," Cavusoglu said on Tuesday.

Harmony between Turkey and Iran is crucial in ensuring the preservation of a fragile ceasefire in Syria - also backed by Russia - that came into force at the end of last year as a basis for peace talks.

Although Ankara says Assad should go, the government has occasionally softened its stance, indicating the president could have some role in determining the country's future.

But Vaez said the Syria talks process was reaching an impasse, while the spheres of influence of Iran and Turkey were colliding in Syria.

"Ultimately Turkey and Iran, as neighbours, will have to live with the outcome of the conflicts now burning around them," he said

"Any sustainable solution will require a regional power balance tolerable for both," he said calling on both sides to recognise the other's interests.