Turkish President Recep Tayyip Erdogan (L) visited Iranian counterpart Ebrahim Raisi in Tehran in 2022
Turkish President Recep Tayyip Erdogan (L) visited Iranian counterpart Ebrahim Raisi in Tehran in 2022 AFP

Iranian President Ebrahim Raisi arrives in Turkey on Wednesday for twice-delayed talks aimed at ironing out past differences and trying to halt the spread of the Israel-Hamas war.

Raisi's visit to Turkish President Recep Tayyip Erdogan comes with the war in Gaza starting to enflame tensions and escalate fighting across the Middle East.

The United States and Britain have stepped up joint air strikes against Iranian-backed Huthi rebels in Yemen in response to their attacks on Red Sea shipping lanes.

Israel meanwhile has repeatedly targeted Tehran-linked figures in Syria and appears to be on the brink of launching a full-scale war against Iran-backed Hezbollah militants in Lebanon.

Iran and Pakistan last week exchanged strikes against "militant" and "terrorist" targets and Turkey itself has intensified artillery and drone strikes against Kurdish groups in Syria and Iran.

The rapid pace of the Middle East escalation forced Raisi to delay his visit to Ankara twice.

Planned talks in Ankara in early January were called off when twin blasts claimed by Islamic State group jihadists killed 89 people at the shrine of assassinated Islamic Revolutionary Guard Corps general Qasem Soleimani.

A trip he had planned for November was cancelled because of conflicting schedules of diplomats involved in consultations over the Gaza war.

The Turkish presidency said the two leaders would appear at a press conference after holdings talks and chairing a meeting of their top ministers during the one-day visit.

The turmoil engulfing the Middle East since Israel went to war in retaliation for Hamas's October 7 attack has added a new layer of complexity to Turkey's close but uneasy relationship with Iran.

Erdogan depicts the Iran-backed Hamas as legitimately elected "liberators" and not the "terrorist" organisation it has been called across the Western world.

He has compared Israeli Prime Minister Benjamin Netanyahu to Adolf Hitler for pursuing an offensive that has killed more than 25,000 people -- mostly women and children -- in Gaza, according to the enclave's Hamas-run health ministry.

Relentless Israeli attacks since October 7 have left much of the besieged Palestinian territory in ruins and starved of food.

But Erdogan had initially defended Israel's right to respond to the Hamas raids that resulted in the death of 1,140 people -- also mostly civilians -- according to an AFP tally based on official Israeli figures.

The militants are still believed to hold around 130 of the estimated 250 people they took hostage in the worst attack in Israel's history.

Analysts note widespread anger in Iran's official and semi-official media about Turkey's continuing trade and diplomatic relations with Israel.

These differences add to existing tensions between the two regional powers in Syria -- where they supported opposing camps in the country's civil war -- and in the conflict between Azerbaijan and Armenia over the Nagorno-Karabakh enclave.

"Relations between Turkey and Iran have always been complex and multidimensional," Istanbul's Centre for Iranian Studies director Hakki Uygur told AFP.

"Turkey has always able to manage it, to somehow to find a middle ground. I think a similar thing will happen now."

Iran's official IRNA news agency said Raisi would be leading a "high-ranking political and economic delegation" on his first official visit to Turkey since his election in 2021.

Iran and Turkey share a 535-kilometre (330-mile) border and a long history of both close economic relations and diplomatic feuds.

Turkey backed rebel efforts to topple Iranian- and Russian-backed President Bashar al-Assad during Syria's civil war.

Iran grew increasingly anxious as Turkey supplied arms to help Azerbaijan beat back Armenian separatists from Nagorno-Karabakh in 2020 and then again last year.

Tehran fears that Baku's resurgence in the Caucasus region could feed the separatist ambitions of Iran's large ethnic Azerbaijani minority.

Analysts believe the Gaza war has helped put regional disputes on the back burner and force the two leaders to seek a joint approach to the Middle East.

"It is possible that Raisi and Erdogan might declare some symbolic measure about Palestine out of the meeting," said Clemson University professor Arash Azizi.

"But I think their focus will be mostly on how to contain the conflict and make sure it doesn't expand further, something that Ankara and Tehran both want."