ANKARA: Iran and Turkey on Monday pledged to work together to stop extremism and bloodshed in the Middle East despite their deep differences over Syria's civil war.
" Iran and Turkey, the two important countries in the region, are determined to fight against extremism and terrorism," Iran's President Hassan Rouhani told a news conference in Ankara.
He said the instability in the region benefited neither the neighbouring countries, nor the world, and said Turkey and Iran agreed to work together.
Turkish President Abdullah Gul commended Rouhani's policies since taking office in August last year, saying they were helping Iran open up to the world.
The diplomatic niceties though papered over a complex and often dysfunctional relationship between the two countries. Those ties have taken an especially bitter turn in recent years as a result of increasing competition between Sunni and Shia Muslim powers across the region.
This has become more pronounced following the onset of the Syrian civil war, in which the two nations have found themselves on opposite sides.
Iran, a Shia theocracy, is the chief backer of Syrian President Bashar al-Assad, while Sunni-majority Turkey has moved from trying to encourage reform in Syria to overtly supporting the armed opposition.
Rouhani has congratulated Assad on his re-election for a third seven-year term last week, in a poll ridiculed by Syrian opposition groups and their Western and Arab backers.
Turkey however blasted the elections as "null and void", saying that it was "out of the question to take them seriously".
The Syrian poll "represents a clear contradiction to the Geneva declaration seeking a political solution," a Turkish foreign ministry official told AFP on Monday.
Rouhani's trip to Turkey, flanked by a crowded delegation of ministers and Iranian businessmen, saw 10 bilateral deals signed in several sectors including finance, tourism, culture and communications.
Iran and Turkey will also chair the first meeting of a high-level cooperation council, a mechanism Ankara has established with its neighbours to promote trade and regional integration.
The Iranian leader asserted his visit "will undoubtedly be a turning point in the two countries' relationship".
It was the first trip to Turkey by an Iranian president since former leader Mahmoud Ahmadinejad made a "working" visit to Istanbul in 2008. The last official presidential visit from Iran to Turkey was in 1996 by Hashemi Rafsanjani.
That visit was marked by controversy when Rafsanjani refused to visit the mausoleum of modern Turkey's revered founder Mustafa Kemal Ataturk -- a routine practice for foreign heads of state. Rouhani also is expected to skip the mausoleum.
Ataturk's secular credentials make him an unpopular figure with Iran's theocratic rulers.
Despite the tensions, both countries have many reasons to work together.
Both are concerned about the rise of sectarian conflicts on their borders, and most of all wish to maintain their close energy and trade ties that have been threatened by Western sanctions targeting Iran.
Turkey is heavily reliant on Iran for oil and gas, having few energy resources of its own. It has been a fierce opponent of Western sanctions that has severely curtailed its access to Iranian fuel in recent years.
Ankara has been accused of circumventing the sanctions by quietly trading gold for Iranian gas.
Turkish prosecutors are currently investigating what they describe as a huge criminal network that used bribes and payoffs to conceal the illicit trade. Turkish Prime Minister Recep Tayyip Erdogan has dismissed the allegations as a foreign plot and put huge pressure on investigators to drop the case.
On a visit to Tehran in January, Erdogan said the two countries were aiming to more than double trade to $30 billion (22 billion euros) by 2015.
He hopes Iran will be able to forge a diplomatic deal with the West over its nuclear programme by the deadline of July 20 that would see sanctions -- suspended since an interim deal was signed late last year -- dropped permanently.
President Gul said that Turkey "strongly supported a deal that will help remove all the sanctions".
Ankara has long defended Tehran's right to peaceful nuclear technology but adamantly opposes any development of nuclear weapons, which it fears would lead to an arms race in the Middle East.
"We don't want any country in our region to possess nuclear weapons. We maintain our desire for a Middle East cleared of weapons of mass destruction," Gul said.
Rouhani said: "Our region should be cleared of not only nuclear but also conventional weapons".
Yet Iran and Turkey have emerged as competitors for influence across the Middle East -- notably in Iraq and Syria -- as well as in Central Asia and the Caucasus.
Even on areas where they might be inclined to cooperate -- such as in the fight against Kurdish separatism -- they have often sought to undermine each other.
Both Turkey and Iran face a threat from Kurdish rebels who wish to break away and form their own country. But instead of working together, each government have sponsored rebels in the other's backyard over the years.
In Ankara, Rouhani said he and Gul discussed Syria and Egypt, and how Iranian-Turkish cooperation could help stop the bloodshed in the region.
"What's important to us is for the two countries to reach stability and security, that the people's vote are determining, and an end to the war, bloodshed and killings between brothers".