Recep Tayyip Erdogan, the charismatic leader of the Islamist Justice and Development Party (AKP) and Prime Minister of Turkey, is embroiled in a significant graft scandal that might precipitate the end of his rule.Erdogan has won three consecutive national elections since 2002, serving as Turkey’s Prime Minister since 2003. He was catapulted to power largely because of widespread disgust with the corruption of the old Kemalist elites. It is therefore ironic that graft may bring Erdogan down.AKP ascendance to a pivotal role in Turkey’s political system came about as a result of several factors: rejection of discredited politicians and their blatant Kemalist secularism, an economic crisis, demographic trends bringing to the fore traditional elements in Turkish society, and the ascendance of an attractive political leader in Erdogan.Erdogan’s governments stabilized the economy and, for a while, demonstrated a cautious approach with regard to enhancing the role of Islam in the public sphere.This was accompanied by continuity in Turkish foreign policy: attempts to join the EU, membership in the Western alliance, and good relations with Israel.But under Erdogan, Turkey gradually adopted policies that amounted to a wholesale attempt to Islamize the country: putting restrictions on the sale of alcohol, enhancing the status of religious schools, encouraging the establishment of Muslim-oriented institutions of learning, and nominating Islamists to sensitive positions in the public sector.Many Turks started complaining about growing authoritarianism at home. This was particularly felt in the Turkish media that was subject to intimidation and takeover attempts. Journalists were sent to jail under a variety of charges. The business community felt informal pressure to conform to Muslim mores. More recently, the banking system was similarly subject to infiltration by government-sponsored Islamists. Changes were also introduced in the foreign policy area. Fueled by Islamist and Ottoman impulses, Turkey devised a so-called “Zero Problems Policy” toward its Middle Eastern neighbors. Instead of the Kemalist hands-off policy toward the Middle East, the new approach emphasized good relations with Muslim neighbors in order to attain a leading role for Turkey in the Muslim world.AS PART of this attempt to gain hegemony in the Arab and Muslim worlds, Israel-bashing became an important tool of Erdogan’s foreign policy, causing deterioration in relations between Ankara and Jerusalem. This policy also reflected a Turkish distancing from the West, basically giving up the long-cherished Turkish goal of becoming part of Europe. (The Europeans are partly at fault for that). The apex of this foreign re-orientation was the September 2013 decision to purchase an air defense weapons system from China, which is clearly and blatantly at odds with Turkey’s NATO membership.The Zero Problems policy backfired as its neighbors went into turmoil and Turkish hegemonic overtures were rebuffed. The political and economic crisis called the “Arab Spring” provided an opportunity for Turkey to sell itself as a model, as a successful bridge between Islam and modernity. But the Islamist zeal emanating from Ankara could not transcend the historic ethnic enmity between Turks and Arabs.Foreign policy failures paralleled growing domestic discontent. The events around Gezi Park in Istanbul this past summer were a spark that galvanized popular opposition. Erdogan seemed to have lost his touch and reacted aggressively to the demonstrators. Eliciting criticism even from allies, Erdogan had to shelve the plan to hold a referendum to make the presidency a stronger political institution for which he could run in the future.Most important, a rift developed between the AKP and the Fetullah Gülen movement. The Gülens are seemingly modern Islamists and an important component of the AKP. They have become increasingly uncomfortable with Erdogan’s policies. For example, they were not happy with Turkey’s new foreign policy, with Israeli-Turkish tensions, and with Turkish support for the Muslim Brotherhood in Egypt.They also criticized Erdogan’s clumsy treatment of the Gezi Park affair.In November, the prime minister announced that he would close down the country’s private exam prep schools, or dershanes, roughly a quarter of which are run by Gülen’s followers. This further estranged the Gülenists, weakening Erdogan’s domestic support.Gülen’s media outlet, Zaman, the largest newspaper in Turkey, has become openly critical of Erdogan. The police and the judiciary, largely under the influence of Gülen, were responsible for the recent arrests of several Erdogan’s protégés under charges of corruption.The prime minister executed a major reshuffling of his cabinet in an attempt to distance itself from the corruption scandal.Erdogan’s leadership is contested these days as never before. It is not clear yet how he and his party, the AKP, will come out of the current political crisis. The secularists in Turkey now have a chance to further erode Erdogan’s popularity. Their own standing in Turkish politics has not improved much despite Erdogan’s excesses. However, the more conservative secular elements on the Turkish political spectrum might build an alliance with the influential Gülens to remove Erdogan.Municipal elections scheduled for March 2014 will be the first serious test of the extent of the political damage to Erdogan, followed by presidential elections in June. Erdogan’s authoritarian streak and strains on the economy will be issues in the campaign. It remains to be seen whether Erdogan’s attempt to blame his domestic problems on foreigners is successful.The results of the municipal and presidential elections will not just be a popularity contest for Erdogan, but a struggle for Turkey’s soul. The writer, director of the Begin-Sadat Center for Strategic Studies, is a professor of political studies at Bar-Ilan University and a fellow at the Middle East Forum.