Many Americans are puzzled by what is going in Turkey. Turkey, a founding member of NATO and a perennial aspirant for membership in the European Union, is the land bridge that connects Europe to Asia. It is a regional superpower, both economically and militarily, and has long been an island of stability in a Near East racked by conflict.

For United States policymakers, Turkey has also long been promoted as role model for the successful fusion of Islam, democracy, and capitalism. It has also been a reliable political partner as a Washington obsessed with seeing its own national security to be based on global dominance has become increasingly unable to dictate developments in the Middle East. Turkey has served as a useful and generally reliable surrogate, able to project its own power and use its considerable diplomatic and economic clout to influence—and even moderate—the behavior of its neighbors. But what is occurring now in Turkey suggests that the wheels might have come off the wagon. The prospect of “losing” Turkey would be a major strategic disaster for both the United States and Europe.

It is first of all important to understand some things about Turkey in general. Everything one may have been reading about the situation in Turkey is at least somewhat true, even when it appears to be contradictory. This is because the Turkish Republic has always been something of a hybrid democracy since its founding by Mustafa Kemal Ataturk in 1923. From the start, it has had leading institutions that have limited the options available to the political parties. The army is the most obvious culprit, priding itself as the guardian of the country’s secular constitution, referred to as Kemalism, but there are also other major state institutions, most particularly the nationalized industries and capitalist-inspired conglomerates and state banks modeled on what contemporary Mussolini was doing in Italy.

State control of large parts of the economy coupled with a faux capitalism that had little in the way of safeguards meant that the government functioned in a corrupt fashion, rewarding supporters and punishing opponents. This pattern of blatant corruption persisted through the 1990s with several major center-right and center-left parties alternating in power around the three military coups that were required to “restore order.” In Turkey one seldom witnesses the on-the-street baksheesh style of low level official corruption prevalent in much of the Middle East and Asia, but governments preceding the current one were unrestrained in awarding contracts that benefitted both supporters and family members.

The Justice and Development Party (AKP) and Recep Tayyip Erdogan are less corrupt than their predecessors, but they are still corrupt. Recognizing that in spite of a secular constitution most non-urban Turks are religious, Erdogan succeeded in dramatically shifting the political playing field by making personal religiosity a plus rather than a minus, creating in the process a new self-consciously Muslim entrepreneurial class which has challenged the secularist dominance in many parts of the economy. Now, for the first time, it is political acceptable to openly demonstrate one’s belief in Islam, and Erdogan has capitalized on that sentiment to build himself a seemingly unassailable political base. This displacement of the country’s former secular elite helped fuel the class and cultural conflict that was evident last summer during the riots in Istanbul.

Critics believe that Erdogan has become empowered by his own sense of political invincibility to take unwise steps to openly repress opponents. He has arrested journalists critical of his government and has not hesitated to describe protesters as “terrorists.” The Turkish parliament is also moving to curb the internet by giving the government power to block websites within forty-eight hours. In the wake of last June’s riots, Erdogan said that “This thing called social media, I think, is right now a menace to society.”

The AKP is generally referred to as a moderate Islamic party, which is probably close to the truth, though it does obscure the fact that it includes numerous religious hardliners whose support has been bought by introducing legislation friendly to political Islam. Erdogan relies on his religiosity for votes and therefore panders to those sentiments, but he is also pragmatic and a strong supporter of economic growth.  He persists in wanting to join the European Union, even though many Turks have cooled to the idea after numerous rejections from Brussels. To break the power of the secularists and replace them with his own supporters, Erdogan had to take on the army, which had intervened in Turkish politics most recently in 1997, when the generals on the National Security Council intervened to remove an Islamist government over concerns that it would subvert the Kemalist constitution.

Erdogan’s agenda led to hundreds of arrests, mass trials, and the imprisonment of military officers in 2012 and 2013. Those detained were charged with plotting to overthrow the government. While there were undoubtedly army officers who wished to remove Erdogan, many of those arrested were innocent of the charge but were perceived to be opposed to the broader AKP anti-secular agenda. Evidence was fabricated and testimony was frequently contrived while those accused were given scant opportunity to challenge the prosecution. Under pressure from the army chief of staff, a newly vulnerable Erdogan is reportedly now considering retrying some of those convicted.

Recep Tayyip Erdogan has been subject to considerable criticism ever since last summer’s riots, his critics claiming that he has become an autocrat obsessed with grandiose development schemes and projects without any consultation. He has also suffered from the failure to manage Turkey’s two-year long Syrian intervention, creating a chaotic situation along the Turkish border that has become a major security concern as well as a political nightmare. The fallout has been such that Erdogan may shelve plans to run for Turkish President later this year.

Prime Minister Erdogan has called recent developments a “judicial coup” and also  an effort to create a “state within a state,” but has so faravoided naming the likely source of his problems, his former political and religious ally Fethullah Gulen. Gulen resides in Pennsylvania and describes himself as a teacher and “imam” of a loosely organized international Islamic movement that includes more than 800 religious schools in more than 130 countries. The movement is based on the Sufi branch of Islam, and encourages interfaith dialogue, non-violence, friendship with the West, while preaching self-reliance. Its schools emphasize science teaching and, in the United States, are both accredited and largely secular.

Erdogan has been claiming that there is a conspiracy against him involving foreigners. He has called out the U.S. Ambassador personally and has cited the United States and Israel as fomenting the unrest, capitalizing on the unpopularity of both countries with the Turkish public, as well as drawing a connection to Gulen, who regards his movement as friendly to both nations. Gulen has met with Israel’s chief rabbi and was one of the few Muslim leaders to oppose Turkey’s 2010 Gaza Flotilla, which ended with the death of nine Turks. Gulen believed that the flotilla organizers made little effort to work out an accommodation with the Israeli government to allow the ships to proceed peacefully. Gulen is also, of course, a legal resident of the United States.

Gulen’s movement does not even have a proper name and no roll of members. Its between three and six million supporters instead refer to it as “Hizmet,” Turkish for service. Gulen, who owns Turkey’s largest newspaper Zaman, helped Erdogan become prime minister in 2002, calling on the support of a shadowy group of followers that he had reportedly infiltrated into the Turkish government, most notably into the police and the judiciary. He initially cooperated with the new government, particularly in the two mass trials of military officers in which his policemen and prosecutors took the lead, but he increasingly began to see Erdogan as a rival rather than a friend. Gulen supporters reportedly have videos of AKP politicians behaving indiscreetly and have even succeeded in bugging Erdogan’s office, resulting in pushback by the prime minister, who cut the funding for a number of charter schools run by Gulen.

The current crisis became public in mid-December when the police detained fifty persons who were being investigated for corruption and graft, reportedly relating to the awarding of construction and real estate projects as well as to the secret trading of gold for oil with Iran. Some of those arrested were close to Erdogan, including prominent businessmen, the head of a major state bank, and the sons of several of his cabinet ministers, three of whom chose to resign. There were also rumors that prosecutors were preparing to arrest Erdogan’s son for meeting with an al-Qaeda financier. A separate investigation was looking into corrupt contracting for the recently completed rail tunnel underneath the Bosporus. Erdogan responded by firing or reassigning 1,700 police officers as well as the prosecutors working on the graft charges and, more recently, by seeking to ban investigation of any official without permission from the government itself.

The Turkish high court rejected the attempt to limit investigations, but Erdogan has now fired back by removing more senior police officers and prosecutors, including Turkey’s second highest police official, Muammar Bucak. He is also introducing legislation to curb judicial independence by increasing the government role in the naming of judges, something that the country’s High Council of Judges is calling unconstitutional. 20,000 Turks demonstrated in Ankara last weekend in support of the judges and, for the first time, Turkish President Abdullah Gul, a former ally of Erdogan, spoke out in support of judicial independence.

The intensity of the conflict between Gulen and Erdogan, which is already having a negative impact on the Turkish economy, is largely being fueled by upcoming elections in 2014. Local elections, including in Istanbul, take place in March, and presidential polling follows in August. If Erdogan is sufficiently damaged so as to lose his grip on power, Gulen figures to be able to fill the political vacuum as kingmaker in a future political alignment, possibly by supporting the Kemalist Republican People’s Party, which currently holds the second largest number of seats in parliament. What such an alignment might mean is not very clear. Gulen on paper looks a more moderate Islamist that Erdogan, but critics believe that his long term strategy is to take power and push a much more radical agenda. If he were to do so, however, Turkey’s still powerful secularists would likely rise up in a revolt that would make last summer’s riots in Istanbul look like a walk in the park.

If a worst case scenario were to develop, the United States interest would be to restore stability as quickly as possible, which would possibly mean a repeat of the fundamental dilemma posed by Egypt over the past year. But Turkey is more complicated, as it is a vital interest for Washington, unlike Egypt. And if Egypt is indeed the model for what might happen, it suggests that the United States would eventually wind up kicking the can down the road by supporting both sides.

Philip Giraldi, a former CIA officer, is executive director of the Council for the National Interest.