Illustration by Peter Schrank

IT IS a thousand years since the Turks arrived in the Middle East, migrating from Central Asia to Anatolia. For half of that millennium they ruled much of the region. But when the Ottoman Empire fizzled out and the Turkish Republic was born in 1923, they all but sealed themselves off from their former dominions, turning instead to Europe and tightly embracing America in its cold war with the Soviet Union.

The Turks are now back in the Middle East, in the benign guise of traders and diplomats. The move is natural, considering proximity, the strength of the Turkish economy, the revival of Islamic feeling in Turkey after decades of enforced secularism, and frustration with the sluggishness of talks to join the European Union. Indeed, Turkey's Middle East offensive has taken on something of the scale and momentum of an invasion, albeit a peaceful one.

In the past seven years the value of Turkey's exports to the Middle East and north Africa has swollen nearly sevenfold to $31 billion in 2008. From cars to tableware, dried figs to television serials, Turkish products, unknown a decade ago, are now ubiquitous in markets from Algiers to Tehran. Already a vital conduit for sending energy from east to west, Turkey is set to grow in importance as more pipelines come on stream. The most notable is Nabucco, a proposed €7.9 billion ($11.7 billion) scheme to carry gas across Turkey from Azerbaijan and possibly Turkmenistan, Iran, Iraq and Egypt. A single Turkish construction firm, TAV, has just finished an airport terminal for Egypt's capital, Cairo, and is building others in Libya, Qatar, Tunisia and the United Arab Emirates. Turks have scooped up hundreds of infrastructure contracts in Iraqi Kurdistan, and invested in shopping malls, hotels and even schools.

These achievements are partly due to an energetic pursuit of trading privileges, such as Turkey's free-trade pacts with Egypt, Israel, Morocco and Tunisia. It is seeking a similar deal with the six-member Gulf Co-operation Council, which includes Saudi Arabia. Earlier this month, teams of Turkish ministers travelled to Baghdad and Damascus to sign a package of 48 co-operation deals with Iraq and 40 with Syria. Covering everything from tourism to counter-terrorism and joint military exercises, the deals could end decades of tension between Turkey and its former Ottoman provinces.

Turkey's prime minister, Recep Tayyip Erdogan, has just been warmly received in the Iranian capital, Tehran, a reflection of the realpolitik that has kept links open despite the Islamic Republic's international isolation. Turkey requires no visas for Iranians, and Mr Erdogan, who has stressed Iran's right to nuclear power for civil purposes, pointedly congratulated Iran's president, Mahmoud Ahmadinejad, after his disputed election win in June. Turkey only recently made an historic breakthrough in relations with another eastern neighbour, Armenia. If the parliaments of both countries endorse the move, diplomatic ties may be restored after a 16-year freeze.

This dogged diplomatic pragmatism has been ardently pursued by the foreign minister, Ahmet Davutoglu, an ebullient professor of international relations who had long advised Mr Erdogan before his appointment in May. Mr Davutoglu, who in a book described the Middle East as “Turkey's strategic depth”, has called for a policy of “zero problems with neighbours”. Reflecting the mild, modernist Islamism of the Justice and Development party, known by its Turkish initials AK, which has ruled Turkey since 2002, the new policy seeks to use the soft power of trade, along with historical links, to project stability beyond Turkey's frontiers. This marks a distinct shift in worldview. In the past Turkey tended to see itself as an eastern bulwark of the NATO alliance, whereas its Middle Eastern neighbours were viewed as threats to be contained.

Whatever Mr Davutoglu's persuasive powers, this reorientation could not have happened without dramatic changes in Turkey. Reforms undertaken partly to meet demands for EU membership have shifted power from threat-obsessed generals to civilian institutions, and to a new, more self-consciously Muslim elite rooted in Anatolia rather than Istanbul, Turkey's Western-looking commercial and intellectual capital. The AK party has also reversed decades of official policy by trying to meet the demands of Turkey's large Kurdish minority (some 14m in a total population of 72m). The granting of more cultural and political rights, and the admission of past discrimination, have soothed tempers not only among Turkish Kurds, but among their ethnic kin in Iraq, Iran and Syria.

Yet a reason for the success of Turkey's kinder, gentler approach is that it takes place in the context of a regional power vacuum. Such relative Arab heavyweights as Egypt and Iraq no longer wield much clout. American influence has also dipped in the wake of its troubles in Iraq. Indeed, Turkey's biggest breakthrough in Arab public opinion came in 2003, when its parliament rejected an American request to open Turkish territory as a second front for the invasion of Iraq. Turkey did allow the use of an airbase to supply the war, but escaped the opprobrium heaped on America's Arab allies who grudgingly lent support to the toppling of Saddam Hussein.

Turkey has also been welcomed back because many Arabs see it as both a moderate counterweight to Iran and as a window to the West. Iraqi Shias, for instance, are still wary of Iranian meddling in Iraq, even though Iraq's main Shia parties have close relations with Iran. Iraq's Kurds, despite age-old tensions with Turkey, have also warmed their relations as trade has boomed and the looming departure of the Kurds' American protectors raises the spectre of isolation. The secular government of Syria, an ostensible ally of Iran, in fact shares little cultural affinity with its stridently Islamist rulers, compared with the AK party's businesslike, tie-wearing officials. Improved relations with Turkey, which now include visa-free travel, bring much-needed relief to Syria, isolated diplomatically and economically backward. In fact, so eager has Syria been to woo Turkey that in 2005 it scrapped a longstanding territorial claim to Hatay, a province granted to Turkey in 1939 by France, Syria's colonial master at the time.

Turkish officials, however, have been careful to explain that their renewed interest in the Muslim east does not mean a chill towards the West. Instead, they present Turkey as a useful bridge, a regional force for peace, and the model of a democracy that is compatible with Islam. Its Western allies have generally shared that view and have not opposed Turkey's eastward shift. Yet such benign indifference could change, if Turkey's prospects for joining the EU die, or if Turkey is seen as undermining attempts to pressure Iran.

Already, Turkey's gentle realignment has carried some costs, most obviously to its relations with Israel. These flourished into a full-blown strategic partnership in the 1990s, before the AK party's rise, when peace between Palestinians and Israelis seemed possible. Joint military exercises and Israeli arms sales brought the two countries' military establishments close, while trade and tourism expanded fast. Israel even offered to shield Turkey from lobbies in the American Congress that sought to punish Turkey for disputing the genocide of Armenians in Ottoman territory during the first world war.

The end of an affair?

But ties have frayed as Turkish public opinion, which now counts for more, has turned increasingly hostile to Israel. Mr Erdogan, a tough, streetwise politician, felt slighted last year when Israel attacked Gaza only days after he had met Israel's then prime minister, Ehud Olmert, who assured him that Turkish-brokered peace talks between Israel and Syria would resume. The bloodshed in Gaza outraged many Turks, who heartily praised Mr Erdogan when he stormed out of a debate with Israel's president, Shimon Peres, at Davos in Switzerland earlier this year.

The Turks were again angered in September when Israel denied Mr Davutoglu permission to cross into Gaza during a visit to Israel. Earlier this month Turkey, citing Israel's failure to deliver an order of military drone aircraft, abruptly cancelled joint air exercises. Israel, for its part, lodged a formal protest at the airing, on Turkish state television, of a serial depicting Israeli soldiers as brutal killers. Some Israeli officials say they detect signs of anti-Semitism that disqualify Turkey from mediating any longer between Syria and Israel.

Turkish officials respond that they have no intention of breaking off relations with Israel, and think they can still be a useful interlocutor with the Jewish state. But they remain indignant. “We might have lost leverage with Israel,” says an AK party man. “But I'd rather be on the side of history, of what is right, of justice.” One of Mr Erdogan's advisers puts Turkey's case more boldly, in a sign of its growing confidence as a regional leader. “We are conditioning relations with Israel on the progress of the conflict,” he says. “This is what the West should do.”