On Friday afternoon, an as-yet-unidentified faction of the Turkish military launched a coup attempt aimed at toppling President Recep Tayyip Erdogan’s government.

The coup leaders, claiming to speak for the entire Turkish Armed Forces, said they’d done so in the name of protecting democracy — despite the fact that Erdogan and his party were democratically elected.

"Turkish Armed Forces have completely taken over the administration of the country to reinstate constitutional order, human rights and freedom," the statement said.

This may sound crazy to American ears, but it makes at least a little sense in the Turkish context. The modern Turkish republic was founded in 1923 by Mustafa Kemal Ataturk, a former military officer deeply committed to a form of democratic nationalism and hard-line secularism now called Kemalism.

The Turkish military sees itself as the guardian of Kemalism, and has overthrown four Turkish governments since 1960 in the name of protecting Turkey’s democracy from chaos and Islamic influence. Each time afterward, the military has returned the country to democracy — though in a degraded form.

Erdogan is clearly a threat to Turkish democracy and secularism. He leads the AKP, a moderate Islamist party that has "reformed" Turkish schools along Islamist lines. He’s cracked down on Turkey’s freedom of the press and pushed constitutional changes that would consolidate dangerous amounts of power in the president’s hands.

The military had been shockingly quiet about these developments in recent years, leading many to believe that Erdogan had successfully cowed them into submission. But this coup attempt suggests — given the stated rationale of the coup launchers — that some in the military are taking up its traditional role as enforcers of Kemalist orthodoxy.

Yet it’s looking likely they’ll fail. According to Naunihal Singh, a political scientist at the Air War College, coups tend to succeed when their leaders convince other members of the military that they will inevitably succeed. If people think resistance is futile, even regime loyalists will just go with the flow.

That doesn’t appear to be happening. Reports on the ground in Turkey suggest that large portions of the military have sided with Erdogan. So, too, have street demonstrators and leading politicians — including Erdogan opponents. The New York Times reports that Erdogan has returned to Istanbul, which he wouldn’t do unless it was safe.

It’s early still, but these are all signals that the coup hasn’t successfully created the perception of inevitability — which means the armed forces will remain divided and the coup will likely fail.

Ironically, this could help Erdogan’s quest for authoritarian control in Turkey. If he is perceived as the defender of Turkish civilian government, his popularity could well soar. He could leverage this popularity into votes in Turkey’s parliament for constitutional changes granting him extraordinary powers, his longtime objective.

If that happens, the coup leaders may have doubly failed. They will have failed to seize control of Turkey’s government and failed to defend Kemalism from its greatest enemy in a generation.