Four years ago, in celebrating the 60th anniversary of Turkey’s membership in the NATO alliance, Secretary General Anders Rasmussen offered unstinted praise. Turkey, he said, “has shown its commitment to stability, security, and solidarity time and time again.” He praised Ankara’s “steadfast commitment” to the International Security Assistance Force (ISAF) in Afghanistan battling the Taliban. And he declared “a new era of cooperation between NATO, Turkey, and countries in the region.”

The “new era,” in fact, ended almost as soon as it allegedly began. Today the relationship of Turkey to NATO and the West is edging toward the brink of collapse: caught up in a miasma of Islamic radicalism, power-grabbing, and blunderingly naïve foreign policy.

The July 15 coup attempt against the government of President Recep Tayyip Erdogan is more a symptom than a cause of the breakdown. Erdogan is widely seen as an Islamist attempting to transform Turkey’s secular constitution, a political arrangement that Turkey’s military has historically defended. Yet the regime blames a Pennsylvania-based Turkish cleric for masterminding the coup, with the knowledge—and even cooperation—of its Western allies. “I have to say that this was done by foreign powers,” Erdogan told a group of foreign investors in Ankara. “The West is supporting terrorism and taking sides with coups.”

Think of that: a member of NATO—a coalition of democracies historically devoted to defending democracy against totalitarian aggression—accusing fellow members of attempting to overthrow its democratically established government.

Some suspect that Erdogan himself orchestrated the botched coup for political advantage. That seems far-fetched, but the crisis has allowed the president to consolidate his power: He has declared a three-month “state of emergency” to expunge suspected enemies of the state. So far, more than 60,000 people have fallen into the government net—fired, suspended, harassed, or arrested. Their ranks include teachers, university deans, judges, police, and military officers. Members of the Alevi religious minority—a Muslim group considered heterodox by the Sunni majority—also fear they will become special targets of retribution. In short, Turkey’s core democratic ideals and institutions are at risk, throwing into doubt its continued membership in NATO.

The 1949 NATO treaty was founded “on the principles of democracy, individual liberty and the rule of law”—ideas antithetical to the totalitarian project of the Soviet Union. The seriousness of this democratic commitment was cemented in an unprecedented insurance policy, contained in Article 5 of the treaty: an “armed attacked against one or more” of its member states “shall be considered an attack against them all.”

With scant experience in democratic self-rule, Turkey fell short of these principles when it was admitted to NATO in 1952. The nation had taken a significant step toward multi-party democracy in 1950, when it elected an opposition party over its secularist CHP party. But the military retained an outsized role, ready to intervene to defend the secular constitution

Turkey’s admission into NATO coincided with a new phase of the Cold War, as the Soviet Union tightened its grip over Eastern Europe. In 1948, the Soviets staged a communist coup that toppled the democratic government in Czechoslovakia. In 1949, Joseph Stalin tried to force the Allies out of West Berlin by blockading the city. In 1950, Moscow gave the green light to North Korea to invade South Korea, embroiling the United States in a hot war on the Korean peninsula.

Hence the strategic and prudential judgment of the West: NATO membership would guarantee that Turkey, a Muslim-majority nation, would not fall under Soviet influence as it sought to work out its political future.

The threat today, however, is that Turkey will succumb to an equally destructive and aggressive ideology: Islamic radicalism. Erdogan and his AKP party are accused of attempting to impose “political Islam” on the rest of Turkey. Others view his actions as a naked power grab, manipulating Islam to mask his political ambitions. Whatever his intentions, Erdogan’s response to the coup has further deepened the divisions in Turkish society and pitted Turkey against its democratic allies.

If an Islamist-style Turkey provokes an armed attack, should NATO come to its rescue? If Turkey continues on its current anti-democratic course, should it even remain in NATO? Some analysts are doubtful. Concludes Gregory Copley: “Turkey has now formally declared the U.S. (and therefore NATO) as its enemy.”

The Obama administration’s neglect of its relationship to Turkey—and of its Middle East allies more broadly—has invited dire consequences. At risk is Turkey’s position as a launching pad for U.S.-led airstrikes against Islamic State forces in Syria and Iraq; the stationing and safeguarding of about 50 U.S. nuclear weapons on the Incirlik Air Base in southeast Turkey; the dominant role of the Turkish navy in the strategic Black Sea; and the willingness of Turkey to continue to absorb millions of refugees from the Syrian civil war. The White House, eager to disengage from the region, never developed a coherent Middle East strategy that put Turkey near the center of its thinking.

Despite all of this, there was a bright moment in the failed coup attempt, a moment mostly ignored by the Western media, which is worth pondering.

As Turkish columnist Mustafa Akyol observed, the events of July 15 repudiated Erdogan’s paranoid narrative of secular politicians plotting his overthrow. When tanks rolled into Istanbul and Ankara, the major opposition parties—some of whose leaders I met last summer on the eve of a tense national election—publicly denounced the coup. Academics, business leaders, mainstream news media, and ordinary citizens also stood against the renegade military. “All of this shows that Turkish society has internalized electoral democracy,” writes Akyol, “and Turkey’s secularists, despite their objections to the Erdogan government’s Islamism, seek solutions in democratic politics.”

If that assessment is right, the nation’s liberal instincts offer a basis for a more hopeful path for Turkey—if it can be seized. After all, the fiercest critics of an autocratic leader, at a moment of national crisis, put partisan resentments aside and stood up for the principle of government by consent of the governed. Democratic reformers took to the streets to help rescue an illiberal democracy.

The Turkish government must not deceive itself—either through paranoia, false piety, or the lust for power. It owes its very existence to NATO and its Western allies and the democratic ideals they represent. If it walks away from this alliance, it steps, alone and conflicted, into the shadows of militant religion.

Joseph Loconte is an associate professor of history at the King’s College in New York City and a senior editor at Providence. His most recent book is A Hobbit, a Wardrobe, and a Great War: How J.R.R. Tolkien and C.S. Lewis Rediscovered Faith, Friendship, and Heroism in the Cataclysm of 1914-1918.

Photo Credit: Marine Corps Gen. Joe Dunford, chairman of the Joint Chiefs of Staff, tours parts of the Turkish Grand National Assembly that were destroyed during the failed July 15 coup attempt in Ankara, Turkey, Aug. 1, 2016. DoD photo by Navy Petty Officer 2nd Class Dominique A. Pineiro.