WHEN Recep Tayyip Erdogan stormed out of a panel discussion with Israel's President Shimon Peres in Davos last January, denouncing Israel's offensive in Gaza and quoting the sixth commandment “Thou shalt not kill”, many wondered whether he had just demolished Turkey's position as the bridge between the Jews and the Arabs, and between the West and the Islamic world.

He certainly won plaudits among many Muslims, not least Iran's President Mahmoud Ahmadinejad. Yet his outburst—and the rancour against America and Europe that many Turks now express—seem not to have done him any harm with the administration of Barack Obama. On the contrary, at a time when America wants to reach out to the Muslim world, Mr Erdogan's popularity may be useful.

After visiting London, Brussels and Prague next month, Mr Obama will travel to Turkey, keeping a pledge to visit a Muslim country in his first 100 days. Delighted Turkish officials see favourable omens: they say it will be the first time an American president has visited Turkey without also making an obligatory visit to its rival, Greece. They interpret Mr Obama's decision to visit as part of a European tour, rather than a Middle Eastern one, as confirmation of Turkey's importance in NATO and a message of American support for Turkey's wish to join the European Union.

One senior official spoke of a new “golden era” in Turkish-American relations, with co-operation on a host of issues: the Arab-Israeli dispute; opening a dialogue between America and Iran to curb Tehran's nuclear programme; stabilising Iraq as American forces leave; and opening energy pipelines through the Caucasus.

Perhaps the most important of these issues is Iran. This week Turkey's President Abdullah Gul, in Tehran for a regional economic summit, met the country's supreme leader, Ayatollah Ali Khamenei. It was the first time the leader of a NATO member state had been given such an audience, said Mr Gul's entourage. Iranian leaders listened as Mr Gul, who recently met the American secretary of state, Hillary Clinton, urged Iran to take up an American olive branch. Mrs Clinton said Iran would be invited to a meeting in The Hague later this month of Afghanistan's neighbours and countries contributing troops to the NATO-led stabilisation mission there.

Still, Turkish officials are holding back their hopes of an early breakthrough between America and Iran. It is hard for “an iceberg to melt overnight”, says one. America will probably not want to move until after Iran's presidential elections in June. It fears that a quick thaw would strengthen the hardline Mr Ahmadinejad, who could claim that his policy of nuclear defiance had succeeded in forcing America to deal with Iran on its own terms. Until then, Turkey hopes America will restrain the incoming Israeli government from turning up hostile rhetoric against Iran, or from trying to attack its nuclear facilities.

Iran, for its part, told Turkey it wants more confidence-building steps from Washington. In public, it shows little sign of softening. Mr Ahmadinejad dismissed Turkey's mediation. Mr Khamenei said America had made “big mistakes” in Iraq, Afghanistan and Gaza. “The American government is continuing the same previous path and there is no sign of efforts to make up for the mistakes,” he said.

Turkey wants to highlight Mr Erdogan's other moves: helping repair Syria's relations with Saudi Arabia and Egypt, and pushing for reconciliation between the two Palestinian factions, Hamas and Fatah. Turkey also claims to have played a part in bringing together the leaders of Afghanistan and Pakistan. “Obama knows that,” says Mr Gul.

As Europe frets about the reliability of oil and gas supplies from Russia—a dispute with Ukraine in January left much of eastern and central Europe freezing—Turkey's position as the alternative route for energy supplies through Georgia should enhance its standing. This fragile corridor would be strengthened if Turkey were to succeed in another ambition: a grand bargain to resolve border disputes involving Turkey, Armenia and Azerbaijan.