The dust is settling in Turkey with the Government in control of all areas by middy, but for a few inconsequential, isolated and declining pockets in districts of Istanbul, Ankara and elsewhere left, according the reports from Turkey. Moving ahead is as important as the failed coup by a military faction, if not more so, as are the implications for Turkey, the region and beyond.

It is a sign of the growing disconnect and distrust between the Western and Muslim world that many of President Erdogan’s supporters in Turkey and elsewhere will see in this coup as a Western attempt to strike back at the direction he was leading Turkey towards. Their suspicions will have been further fuelled by the attempt of some media analysts on western TV channels to look for signs that Erdogan was in a precarious position, and some visible unhappiness when this turned out to be incorrect once he arrived in Istanbul and addressed the nation. Though the power of social media is widely acknowledged, the fact that when Erdogan was on holiday away from the major cities and used Facetime to send a message of resistance to the people, rather than this being acknowledged as a savvy move, it was labeled a sign of weakness. One analyst even stated that there were unconfirmed reports he had fled the country.

To their credit, the more sober western analysts including former diplomats decried this threat to Turkish democracy and President Obama and the NATO Secretary General quickly voiced support for Turkish democracy. The stability of Turkey, so seminal in the struggle to regain some semblance of stability in a deeply unstable region, with Syria and Iraq in disarray, and mass movement of those displaced, is self evident.

This failed attempt highlights a number of factors. While there have been a number of successful military coups in Turkey in the past, this one follows in the unsuccessful footsteps of the 1960 attempt, quixotically led by military cadets, which had not even secured the support of the Ankara military region commander and his forces. While the present enterprise may have included some elements from all three services, it lacked the support of the high command and the broad military establishment. If that had been secured Turkey might well have been in for a period of turmoil and disorder reminiscent of what transpired in the streets after the removal in 1960 of Prime Minister Adnan Menderes and his subsequent execution.

But times change and the majority support Erdogan enjoys from the AKP party plus the declared support of the opposition leaders in this difficult time has been his and Turkey’s bulwark and a tribute to Turkish democracy. Nonetheless Turkey, overtly an economically and otherwise strong country, is beset by deep polarisation which has been accentuated by Erdogan constantly pushing the envelope of centralised power; and unwisely not heeding or giving safety valve space to the historical liberal, secular, and Kemalist opposition which remains significant and sizeable. The collapse of the peace deal with the Kurds has also been destabilising.

The real issue now in Turkey is whether Erdogan and the AKP will, instead of doubling down on extending their present policies as might well be their inclination, instead move towards a more inclusive and halfway secular form of governance as foreseen in the constitution, which would be the best outcome. Otherwise the polarisation in Turkey will remain and may intensify.

In the region Erdogan has begun to repair relations with Russia, and has mended ties to Israel permitting the restoration of Turkish aid to Gaza, so vital for the beleaguered Palestinians. The West has been unhappy with its suspicion of Turkey’s tardiness in tacking ISIS within, and in Syria, but after recent terrorist attacks targeting the country there can be no doubt of Turkey’s resolve.

The West may hope that Turkish action against the Kurds in Syria and Iraq, who have been effective armed actors against ISIS, may abate but Turkish historical hardline stance on this issue will probably remain, as it springs from a consensus shared with the military. However Turkish military support for the anti-ISIS campaign in Syria more would likely become more in-sync with USA.

For Pakistan, Turkey remains with China a true and tested friend through thick and thin. Turkey is one country where there is a deep and popular affection for Pakistan and its people, which is fully reciprocated. Erdogan and all Turkish leaders past and present, AKP and otherwise, have stood by Pakistan, and their objective has been that any material, technological, economic, and political support for Pakistan should assist us to develop on its own.

Pakistan therefore has a vital stake in Turkey, its stability and continued progress. Prime Minister Nawaz Sharif was amongst the first to issue a strong statement of complete support and solidarity with President Erdogan, the democratically elected government of Turkey, and the democratic institutions of Turkey. The Special Assistant to the Prime Minister for Foreign Affairs followed up in an early morning call of support to the Turkish Foreign Minister. This support has been widely appreciated in Turkey.

For Pakistani leaders the lesson is that the strength of democracy rests in delivering economic progress to the people, the hallmark of Erdogan’s legacy despite all else, and in building up cohesive and representative party structures.

Even if Pakistan still has some way to go towards that objective, the events in Turkey, however short-lived, show that Pakistan despite enormous external and internal challenges remains a model of stability in an increasingly uncertain and disordered region. Furthermore as terrorist attacks unfortunately have become more prevalent globally this should lead to more understanding of what Pakistan has been facing alone for over a decade. These factors should also give rise to reflection and reconsideration by critics of Pakistan in the USA and elsewhere on the importance of supporting stability in Pakistan for the sake of the region, including neighbouring Afghanistan.