Whatever happened to the idea that Turkey was the coming power in the Middle East, with its surging economy and stable democracy under a mildly Islamic government which might be the model for Arab states as they ended decades of police state rule in 2011? Turkey seemed perfectly positioned to lead the way, with no serious enemies in the region and with good relations with the US and the EU. Oversimplified headlines comparing modern Turkey with the Ottoman empire in the days before it became a great power in the 16th century did not seem wholly exaggerated.

Two years later, none of these good things has come to pass for Turkey, and it is very short of friends in the Middle East. It has managed simultaneously to make enemies of the four Shia powers to its south and east: Iran, Iraq, Syria and Hezbollah in Lebanon – as well as the Sunni monarchies of the Gulf with the exception of Qatar. Turkish pilots are kidnapped in Beirut and Turkish truck drivers arrested in Egypt. Turkish support for the former president of Egypt Mohammed Morsi and the Muslim Brotherhood has infuriated the military regime, which has even intervened to stop the showing of Turkish soap operas on Egyptian television.

Most serious of all, Turkey’s entanglement in support of what may well be the losing side in the Syrian civil war is bringing nothing but disaster. It did not have to be like this: at the start of the Syrian uprising Ankara was well placed to play a moderating role in the crisis, since it was on good terms with President Bashar al-Assad but able to put pressure on the insurgents who depend on keeping open the 560-mile Turkish-Syrian frontier. But the Turkish Prime Minister, Recep Tayyip Erdogan, overplayed his hand, assumed that Assad would go down as quickly as Muammar Gaddafi in Libya and gave full support for the rebels. Many other governments made the same mistake, but the consequences of the failure of the insurgents to win a decisive victory is most serious for Turkey. Whatever Turkey thought it was doing in Syria, it has not succeeded with jihadi and non-jihadi fighters in Syria as frightened of each other these days as they are of the Assad government. The question is less about the departure of Assad as Syrian leader and more about the long-term survival of the rebels as more than a coterie of warlords.

The ability and patience of Erdogan and the AK party in gradually taking over the levers of powers in Turkey over the past 12 years is in marked contrast to the crudity of their policy in Syria and Iraq. Perhaps the best explanation is simple hubris stemming from Erdogan’s election victories in 2002, 2007 and 2011, when he outmanoeuvred the Turkish army which had been the nemesis of previous Islamic and democratically elected Turkish governments. But beyond the Turkish frontiers, his sure political instincts deserted him and he became the master of miscalculation, involving Turkey in a ferocious civil war in Syria and a near civil war in Iraq. Iraqi politicians were alternately bewildered and amused by Turkey’s blundering interference.

Turkey could have played a constructive role that would have much enhanced its influence and saved a lot of lives if it had taken a more neutral stance enabling it to mediate between different sides. Instead, it did the exact opposite, joining a coalition of Sunni powers of which other members such as Saudi Arabia were viscerally sectarian, and thereby ensuring that the Shia powers were alienated. Even within this Sunni coalition, Turkey is isolated because of its support for the Muslim Brotherhood in Egypt and is paying a heavy economic price. Trade routes through Iraq and Syria have been cut and the UAE is reported to be cancelling a $12.5bn investment in coal extraction that would have provided 4,000 jobs. Investors in Dubai and Kuwait are wary of deeper involvement in Turkey.

The poison of sectarian hatred in Syria is slowly spreading into Turkey with the 15 to 25 million Turkish Alevi sympathising with their fellow Alawites in Syria.

Erdogan’s denunciations of the Alawite-dominated government in Damascus can seem as having implications for the Turkish Alevi who have long complained of discrimination against them by a Sunni state that denies them separate religious rights. This sense of discrimination still has a long way to go before it resembles the blood-drenched sectarianism of Iraq and Syria. But the potential for an explosion is growing and, once violence starts, it will be difficult to stop because the Syrian civil war gives a greater sense of crisis to Turkey’s other deep political differences.

Whatever happens, Turkey’s moment in the Middle East seems to be passing with strange speed and may be one of the great lost opportunities of regional history. The New Ottoman rhetoric, aside from forgetting how unpopular rule by the old Ottoman empire was among its subjects, now seems delusory. It could also get worse. Relations with Iran are showing slight signs of improvement but, if they were to deteriorate again, Iran would have an incentive to undermine any understanding between the Turkish government and Turkey’s Kurds. Erdogan will this week reveal what concessions he is willing to make to the Alevi and the Kurds, which will not be as much as they want but may be enough for them to feel they are making progress in acquiring full civil rights.

Erdogan’s blunders in the sectarian political swamp that stretches between Iran and the Mediterranean remind me of Tony Blair’s misadventures in the Middle East. Blair, like Erdogan, was a consummate politician on his home turf with sure political instincts and, again like the Turkish Prime Minister, won three elections in a row. He was accustomed also to dealing with US and EU leaders. But when it came to Iraq and Lebanon, his judgement deserted him and hubris misled him.

The picture Blair presents in his autobiogaphy of Iraq post-invasion shows astonishingly little understanding of what was happening. Al-Qa’ida and Iran appear out of nowhere like aliens from a neighbouring planet, as agents of disruption. Erdogan, likewise, seems baffled about why his venture into the Middle East has gone so very wrong.