President Obama shakes hands with Turkish President Recep Tayyip Erdogan in Antalya, Turkey on November 15, 2015. (AP Photo/Lefteris Pitarakis)

A core principle of the North Atlantic Treaty Organization (NATO) is that member states adhere to democratic values . So what happens now that Turkey, a longtime NATO member, has suspended a number of legal protections in the weeks and months following the July 15 coup attempt?

Immediately after part of the military tried to overthrow his government, Turkish President Recep Tayyip Erdogan retaliated with a widespread purge of large numbers of police officers, judges and soldiers. By late July, the Turkish government's crackdown had extended to the private financial sector , as well as the country's universities. The government detained as many as 50,000 in what one news report called "the biggest purge in Turkey's modern history."

[How Erdogan's anti-democratic government made Turkey ripe for unrest]

Turkey's ties with the West are strained

As discussed here in the Monkey Cage, Erdogan met with Russian President Vladimir Putin in early August after criticizing the U.S.-European response to the coup. That Erdogan sought closer ties with Putin is a remarkable outcome in light of the fact that Turkey and Russia have been at loggerheads over Syria.

From Turkey's perspective, NATO and the West may have "failed the solidarity test" by offering Erdogan little reassurance after the coup attempt. Washington, for instance, made no promise to grant Turkey's extradition request for Fethullah Gulen, the U.S.-based Turkish cleric who Erdogan claims was the coup's mastermind. AWhile the two nations have been cooperating in the ongoing fight against the Islamic State, significant tensions remain.

[Why it's good for dictators to have dictator friends]

These recent developments — and years of creeping authoritarianism by Erdogan and his AKP party — have led some foreign policy analysts to call for Turkey's expulsion from NATO.

Doug Bandow at the Cato Institute called for a "civil divorce," noting that "As Ankara moves toward an authoritarian one-party state, its membership in NATO becomes ever more incongruous."

Another Cato scholar, Ted Galen Carpenter, last year wrote that "NATO is supposed to be an alliance of peaceful democracies. Yet evidence continues to mount that Turkey fails to meet [that] standard." More recently, Carpenter wrote, "Does America really want to risk its security to protect such allies, especially when it purports to lead an alliance of enlightened democracies?"

[Here's why there are so many conspiracy theories about the Turkish coup]

But Erdogan's increasingly authoritarian stance doesn't necessarily provide the grounds for booting Turkey out of NATO. A brief look at the historical record shows that the United States has a long and complicated legacy of supporting autocrats both inside and outside of NATO.

There are many examples in U.S. history

Michael Poznansky's research with John Owen suggests that as a general rule, the United States is far less likely to dump a dictator if there is a credible ideological alternative to liberal democracy and capitalism that opponents might institute — if given the chance to govern.

In 1961, for example, President John F. Kennedy summarized what he saw as three U.S. options regarding the longtime Dominican Republic dictator Rafael Trujillo: "In descending order of preference: a decent democratic regime, a continuation of the Trujillo regime or a Castro regime. We ought to aim at the first, but we really can't renounce the second until we are sure that we can avoid the third."

When communist forces emerged as viable competitors in some countries in the late 1970s, Jimmy Carter — perhaps the most dovish president during the Cold War — turned a blind eye to Ferdinand Marcos's electoral fraud in the Philippines (1978) and Chun Doo Hwan's crackdown on student protesters in South Korea (1980).

NATO allies don't always play by the rules

That's what history shows, but what about the supporting data as it pertains specifically to NATO allies? We decided to compare Turkey and Portugal, a NATO founding member in 1949 that didn't become a full democracy until 1976. Turkey, which joined the alliance in 1952, has fluctuated between full-fledged democracy and a regime with strong authoritarian characteristics (the same is true of Greece, which also joined the alliance in 1952).

The two graphs below chart the fluctuations in regime type for Portugal and Turkey from the year each entered the alliance through 2013. We coded each country's "polity score" using the Polity IV index. Scores ranged from -10 (most autocratic) to +10 (most democratic). The horizontal red line represents a score of +7 on the Polity index — this is the threshold political scientists commonly use to gauge whether a country is a mature and stable democracy.

These graphs clearly show that both Portugal and Turkey have, at various times, fallen far short of this threshold.