FEW COUNTRIES OCCUPY a geopolitical space of such sensitivity as Turkey, or have played such a range of critical and overlapping international roles. It has been a gateway and a bridge to Europe, most dramatically in recent months for hundreds of thousands of Syrian refugees, as well as a conduit for energy supplies. It has been a buffer to revolutionary Iran, and a barrier to Russia’s southward ambitions since long before it joined NATO in 1952 (and even more so since Vladimir Putin decided to leap into Syria’s maelstrom). It has been an anchor to the ever-turbulent Middle East, and in some ways also a model to other Muslim countries of a relatively tolerant, relatively democratic and economically quite successful government.

Yet the country has all too often failed to show both strength and responsibility at the same time. For decades after the second world war Turkey stuck to its own business and remained a staunch ally of the West, both in NATO and as a founding member of the OECD, yet it was not strong. Its economy was doing badly, and under the generals it mostly avoided putting much effort into foreign affairs—with rare exceptions, such as when it invaded and partitioned Cyprus in 1974. Troubles with neighbours such as Greece, Bulgaria and Armenia were allowed to fester, and ties with Europe and America remained formal and cool. With Israel, it maintained a tacit, businesslike alliance. As for its Muslim backyard, Turkey shunned it altogether.

This aloofness, mirroring a national penchant for mistrusting outsiders, came to an abrupt and welcome end when the AK party took power. Under the guidance of Ahmet Davutoglu, who served as a foreign-policy adviser and then foreign minister before becoming prime minister, the country proclaimed a policy of “zero problems with neighbours”. The sudden wave of warmth from Ankara produced immediate results. Old quarrels, even with such once bitter foes as Armenia or the Kurds of northern Iraq, were set aside. Europe seemed ready to open its doors to Turkey, if only by a crack. Russia became an important trading partner. Turkey’s Arab neighbours welcomed back their former Ottoman master with enthusiasm. Exports to the Middle East boomed. For a time the forthright Mr Erdogan was the most popular leader in the region. Turkey looked strong.

Don’t mention the EU

As for being responsible, in many ways it has performed less well. That is not entirely Turkey’s fault. Part of the reason its accession to the EU has got nowhere has been the EU’s muddled, many-headed set of policies. In the wake of the recession and the debacle over Greece, Europe also looks less attractive now than when talks began in 2005. Yet the AK party’s leadership has been irresponsibly quick to take offence. Even if the EU did unilaterally freeze negotiations on about half the 33 “chapters” that have to be completed before accession, Turkey need not have relaxed its efforts to comply with what the EU calls its acquis (its common set of rules). By doing so, the AK government signalled that it sees things like freedom of the press, judicial independence and fighting corruption as part of the price of membership rather than as valuable goals in their own right.

Such legacies have lately put Mr Erdogan and his European counterparts in an uncomfortable spot. Faced with the deluge of refugees passing through Turkey on their way to western Europe, they have horse-traded stronger Turkish border controls and security measures for European cash, travel concessions for Turks and promises to revive Turkey’s stalled plans for EU entry. Neither side has come out looking good. Turkish officials have indicated that they regard Europe’s €3 billion aid package for the refugees as merely a first instalment. The EU, for its part, has voiced growing concern over issues of civic freedoms and human rights, and in particular Turkey’s renewed suppression of the Kurds.

There are bright spots: the accession process is moving again, and growing pragmatism from all parties to the Cyprus conflict, including Turkey, bodes well for a peace deal. Still, Mr Erdogan’s hope to take Turkey into the EU by 2023, when it will celebrate 100 years as a republic, looks as forlorn as ever.

But it is in the Middle East, and in particular over the civil war in Syria, that responsibility comes most into question. Instead of being a wise friend and mentor to troubled neighbours, Turkey has been in turn overly naive, overly indulgent and overly stubborn. Above all, it has shown that it does not have much of a grasp of the region’s combustible complexity. “Frankly, I don’t know what they are trying to achieve,” says an exasperated UN official closely involved with Turkey and Syria.

That may be partly because of its aloofness. Between the Ottoman defeat in the Middle East in 1918 and Mr Erdogan’s arrival in office, Turks had scarcely glanced at the place. As the Arab Spring erupted in 2011, the government chose to view events through the prism of Turkey’s own story: the true people, which is to say the pious Sunni Muslim working class, were at last casting out their Westernised military elites. The AK party warmly embraced the region’s newly emerging Islamists and suddenly turned a cold shoulder to the autocrats it had only recently wooed as customers for Turkish goods.

In Iraq, Turkey voiced support for Sunni parties as protests mounted against discrimination by the Shia-majority government, only to be blindsided when Islamic State exploited Sunni grievances to carve out a caliphate. In Egypt, say well-informed Turks, Mr Erdogan’s people advised the Muslim Brotherhood during its brief stint in office to replicate such AK party tactics as flooding the supreme court with their own loyalists. The military junta now in power is furiously hostile to Turkey.

In Syria Mr Erdogan, who had only recently spent time on the beach with the Assad family at a Turkish resort, lent full support to the uprising against the Syrian dictator. Like many Western intelligence agencies, his own was convinced that the country’s 70% Sunni majority would quickly prevail. It seriously underestimated the tenacity and viciousness of a minority regime with its back to the wall. “What were we thinking? We are not a mukhabarat country,” says a critical columnist, using the Arabic word for secret police. “And here we were marching into a place with the meanest mukhabarat on the planet, backed by two mukhabarat superpowers, Iran and Russia.”

Thanks two million

To its immense credit, Turkey has offered a haven from the fighting to refugees from the Syrian civil war. “In Europe we’ve had no concept of just how generous the Turks have been,” says a diplomat in Ankara. Well over 2m Syrians have sought shelter in Turkey. Its government has spent perhaps $10 billion building spotless camps and providing free schools, health care and food. The vast majority of Syrian refugees live outside the camps but receive the same benefits and are free to move inside Turkey.

Yet Turkey has been prickly about guarding its sovereignty. Foreign agencies say their money is welcome, but their programmes and supervision are not. The UN has not been allowed to register or process refugees, and refugee camps are strictly off-limits to visitors, including members of Turkey’s own parliament. Although Syrians are grateful for Turkey’s help, few want to live on handouts. As “guests” of the country, they have not been allowed to work, though under new rules introduced in January they can now apply for work permits after six months.

Most worrying is Turkey’s role in the war itself. Having excommunicated the brutal Assad regime, it has found itself sucked ever deeper into the Syrian swamp. Together with Western and Arab allies it has aided rebel factions. It has also—sadly to deaf ears in the West—repeatedly called for the creation of a zone to protect civilians inside Syria. But its secretive military aid, say Western observers, was for too long handed out with little discrimination, and its volume was never enough to turn the tide.

Nor did Turkey back up its diplomatic pleas with firm offers or action. Despite being a NATO member, and despite the evident nastiness of Islamic State, it did not let the American-led coalition fighting IS use its air bases, or even its air space, until about nine months after air strikes against IS began in September 2014. Since then its role in the coalition has mostly involved bombing not IS but the Kurdish rebels of the PKK.

The Turkish security establishment’s wings may have been clipped at home, but its obsessive view of the Kurdish issue as the country’s pre-eminent threat has been allowed to prevail abroad. This has increasingly entangled the country in both Iraq and now Syria, whose Kurdish minority has carved out an enclave along Turkey’s border. To Turkey’s horror, the West has praised it as the most effective force on the ground against IS.

Perversely, when suicide-bombers ripped apart a peaceful anti-government protest by mostly Kurdish groups in Ankara in October, killing over 100 people, AK party spokesmen pointed fingers at the PKK. Yet it quickly became clear that the perpetrators of Turkey’s worst-ever terrorist atrocity in modern times were members of a Turkish IS cell.

Until stricter controls were imposed last year, Turkey allowed virtually unhindered transit to anyone heading to or from the war in Syria. Within Turkey hundreds of suspected Islamist radicals were released from police custody after cursory investigation. At the same time the government has slapped charges of terrorism on police and journalists exposing the supply of weapons to Syrian rebel groups by Turkey itself. And until recently Turkey had suspended security co-operation with France, out of pique over French statements on Armenian genocide.

Since the Ankara bombing, and even more since an IS suicide-bomber killed ten tourists in Istanbul on January 12th, Turkey’s government has begun to take the internal threat from IS radicals far more seriously. Shocked by Russia’s forceful intervention in Syria, Turkey has also begun to reassess its relationship with that country. At the end of November Turkish jets shot down a Russian warplane which they claimed had strayed into Turkey’s airspace, causing a storm of Russian indignation. Despite threats of sanctions and a spike in Russian air strikes against Turkish-backed rebels in Syria, Turkey held its ground.

Further afield, Turkey has quietly eased strains with Israel, edging away from its aggressive reaction to an Israeli attack on a Turkish aid ship destined for Gaza in 2010. Mr Erdogan’s government also appears to be sincere about wanting to get its EU agenda back on track. Rather than throwing its weight behind Saudi Arabia, a fellow Sunni power, in its struggle against Shia Iran, Turkey has kept doors open to both sides. Perhaps in foreign affairs at least, it has begun to balance power with responsibility.