ISTANBUL— If journalists tend to rush in where angels fear to tread, I was saintly during a dinner in London recently with two émigré friends from Egypt.

They were united in their horror over the crackdown against supporters of the deposed president, Mohamed Morsi. And they both feared that the situation could get much worse. But otherwise they harangued each other over the rights and wrongs of the coup.

By betraying the revolution that brought him to power, Morsi was responsible for his own demise, said one. No, said the other, democracy gives elected leaders the freedom to make mistakes. Any correction by military intervention only makes things worse.

Then they turned to me and asked how the situation looked from Turkey, where I live, a country often proffered as a model for the hopeful peoples of the Arab Spring.

It seemed insensitive to say — and so I didn’t — that after three military coups in just over 50 years, Turkey may have settled its debate. True, there is a die-hard minority of ultrasecularists who wouldn’t oppose military intervention if they thought it would work. Yet most of them concede that the generals are hopeless as defenders of democracy and make even worse politicians.

The Turkish military’s continued efforts to justify its tutelage over the political process have badly backfired. When it tried to preserve enormous powers for itself in the 1982 Constitution, it instead created the conditions for the rise of the current government of the Islamist-leaning Justice and Development Party — the military’s sworn ideological enemy.

Every time the courts shut down a supposedly “anti-secular” party, another one grew back, and like a pruned tree, stronger than before.

And so Turkey’s generals are cowed. A government with an Islamist bend has free rein; it even controls the police. In any event, the demonstrations that racked the country’s main cities in May and June were not about overthrowing an elected government; they were about trying to make it more accountable.

So yes, many Turks are concerned that Egypt faces a painful learning curve they know only too well.

But this does not begin to explain why the government in Ankara denounced the coup against Morsi with a virulence that took its own foreign policy gurus by surprise. Some local pundits warned that, while it was very well to criticize the Egyptian military for seizing power, this ignored just how unpopular the Morsi government had become and how it would complicate relations with the new Egyptian regime Still, the Anatolian News Agency, a semiofficial body that toes the government line — and that refused to cover recent anti-government demonstrations in Istanbul — live-streamed a pro-Morsi protest in Cairo’s Rab’a al-Adaweya Square.

Andrew Finkel

Maybe the Turkish government simply couldn’t accept the loss of a soulmate in the region. Morsi was feted at the A. K. Party’s national congress last September and hailed as an apt pupil of the Turkish model. The Turkish government regarded its alliance with the Muslim Brotherhood in Egypt as an important bulwark not only against the Shiite clerics in Iran and Iraq but also against the monarchies of Saudi Arabia and other Sunni states in the Gulf.

After the collapse of Ankara’s good-neighbor policy — efforts to mend fences from Tehran to Damascus — Morsi’s collapse was the latest blow to Turkey’s ambitions as a regional power. Up until the coup, Erdogan spoke of an impending visit to the Gaza Strip, which would have impressed both his electorate and supporters of the Arab Spring. Now that trip, which requires passing through Egypt’s Rafah Crossing, seems an impossible dream.

I didn’t have the heart to tell my dinner companions this, but the Turkish government’s unqualified condemnation of Morsi’s overthrow stems less from a concern for the Egyptian people than a desire to recast its own troubles at home. It suits Erdogan to play the role of the victim by portraying the recent demonstrations in Turkey as attempts to foment a coup against him; they simply cannot appear as legitimate protests against his abuses of power. Water cannons and pepper spray had to be deployed to control dissent, Erdogan is signaling. Because what happened in Egypt cannot be allowed to happen in Turkey.