Conversely, if the HDP fails to breach the 10% threshold, the AKP is likely to inherit almost all of their seats, bringing Erdogan closer to his presidential dreams. But the AKP will still need at least 330 seats if it is to put any constitutional amendments to a referendum.

The AKP’s fate hinges on two critical factors. One is some 15% of the electorate, many of them AKP voters, who remain undecided. The other is the Kurds. They are contesting parliamentary elections for the first time under the banner of the Peoples' Democracy Party (HDP) that is reaching out to Kurds and Turks alike. A growing number of pollsters reckon the HDP will clear the minimum 10% of the vote needed to win seats in the parliament — if only by a whisker. Under Turkey’s complex electoral system, known as the “d'Hondt" system, this would thin the AKP’s share by around 30 seats.

Recent polls show that the AKP’s share of the vote will slip from the record 49% it received in the 2011 parliamentary elections. Some venture it may not even win enough seats to form a ruling majority. This requires 276 seats in the 550-seat legislature. But as recent elections in Israel and Britain have shown, pollsters can get things badly wrong. Yet, while nobody disputes that the AKP will once again get the highest share of ballots, party insiders privately concede that the glory days are over.

Even the combative president is sounding unsure. “There is an apathy among the [political] parties [and] among voters,” he said in a televised interview on A Haber, a pro-government channel. “These elections will hold surprises until the very last minute”.

For the last 12 years, Turkey’s Islamists led by President Recep Tayyip Erdogan seemed invincible. His Justice and Development Party (AKP) romped from one electoral victory to the other, each time snatching a bigger part of the vote. But with less than a fortnight left to go before the June 7 legislative polls, the AKP is looking fragile for the first time.

Investors believe the best result for Turkey is one where the AKP secures a slim ruling majority, the current incumbent Ahmet Davutoglu remains prime minister, and the Kurds get in. “This would keep Erdogan in check and allow the AKP to relaunch democratic reforms and economic growth,” said a Western diplomat who spoke to Al-Monitor in Ankara on strict condition of anonymity because of the sensitive nature of the subject.

The prospect of coalition rule is stoking fears of a return to the 1990s, when a string of corrupt and ineffectual multiparty governments drove the economy into the ground. But if the result is a hung parliament, a coalition will be unavoidable.

It is customary for the president to invite the leader of the front-runner to try his hand at forming a government. The conventional wisdom is that the AKP would likely team up with the ultranationalist Nationalist Action Party (MHP), which is expected to place third with about 16% of the vote. This could spell trouble for the already faltering Kurdish peace process. But, for many, an increasingly autocratic Erdogan endowed with executive powers would be a far worse outcome, especially if the Kurds are shut out of parliament.

Either way, Erdogan is taking no chances. As president he is constitutionally bound to impartiality. But unfazed by such strictures, Erdogan is charging through Anatolia, waving Qurans and demanding that voters give the AKP “at least 400 seats.”

There are several reasons for the AKP’s waning popularity. The wear and tear of incumbency is one. The biggest is Erdogan himself. As a three-term prime minister from 2003 to 2014, Erdogan was once hailed as the greatest reformer since the founder of modern Turkey, Kemal Ataturk. The Turkish economy recovered, growing at an annual average 7% until 2007. The rural masses were eased out of poverty. Shiny, new airports, hospitals and highways were built together with affordable housing. At the same time, Turkey’s domineering generals were tamed, paving the way for now-stalled membership talks with the European Union and overt displays of Muslim piety.

Erdogan is also the first Turkish leader to bargain for peace with Abdullah Ocalan, the imprisoned leader of the outlawed Kurdistan Workers Party (PKK). Under the AKP’s watch, bans on the Kurdish language were partially eased, though education in the Kurdish language in state schools remains forbidden. Turkish state television now offers broadcasts in both Kurdish dialects. But in a crude bid to woo nationalist voters, Erdogan has changed tack: The HDP is “a bunch of terrorists” and ought to be kept out of the parliament. There is “no Kurdish problem,” he now claims.

Some Kurds detect a link between the president’s hawkish rhetoric and the recent spate of attacks against HDP offices across the country. There were at least 127 at last count, and rising.

“The AKP that paints the HDP as enemies and dangerous is responsible for all these attacks,” the PKK said in a statement, even as Davutoglu, the prime minister, issued a condemnation.

Erdogan’s polarizing tactics show signs of backfiring.

Pro-AKP Kurds, including devout Muslims, are said to be defecting to the HDP in droves. Allegati ons that the government initially backed Islamic State (IS) jihadists against Syria’s Kurds in the battle for Kobani played a big part.

Another big reason is the HDP's young and charismatic co-chair Selahattin Demirtas, who with his wit and common touch is drawing voters of all stripes.

On the diplomatic front, things are not looking any rosier.

Gone are the days when “Turkish soft power” was the buzzword in the think-tank circuit. It has fallen out with Egypt and Israel alike. “Turkey under Erdogan is a loose cannon,” the Western diplomat said.

Turkey’s zealous promotion of regime change in Syria has certainly raised eyebrows. Syrian rebels of all stripes, including militant Islamists from Ahrar al-Sham, live freely in places like Urfa, Hatay and Gaziantep. Although the government has tightened up security along its 900-kilometer (560-mile) border with Syria, IS militants continue to use Turkey as a transit route for fresh recruits.

The president’s lavish lifestyle in his garish new multimillion-dollar Ottoman-style palace in Ankara is another headache. Photographs of his wife, Emine, and daughter, Summeye, sipping water from gold-rimmed crystal wine glasses, said to cost $300 apiece, have jarred the pious. Mehmet Simsek, the finance minister, sparked further outrage saying that some $1.3 million spent on a fleet of posh official cars was “peanuts.”

And the AKP continues to be dogged by a massive graft scandal implicating the Erdogan's and the AKP's business cronies in bribery and tender rigging, which erupted in December 2013.

For a while it seemed that Erdogan was able to get away with claims that a so-called global cabal bent on toppling him had orchestrated all of this. The chief culprit, he claimed, was his former ally, Fethullah Gulen, a Pennsylvania-based Sunni Muslim cleric. According to this version, Gulen and his disciples in the judiciary and the police concocted all the evidence, including leaked tape recordings of conversations about money that allegedly took place between Erdogan and his son Bilal.

The government has since reassigned, sacked and jailed hundreds of judges, prosecutors and police officials on thinly supported charges that they were part of “a terrorist network” plotting a coup. The witch hunt has assumed farcical proportions; Hidayet Karaca, the head of Samanyolu, a pro-Gulenist TV channel has been behind bars since December on the outlandish claim that he conveyed Gulen’s instructions to police and prosecutors in coded messages via a popular mini-series called “Tek Türkiye.”

A pair of judges, who ruled in favor of his release, were swiftly imprisoned as well.

Turkey may no longer be the world’s biggest jailer of journalists, “but it ranks third in the world in terms of the number of journalists subjected to police violence,” said Erol Onderoglu of Reporters Without Borders in an interview with Al-Monitor. The Paris-based watchdog ranks Turkey 149th of 180 countries for press freedom.

Yet as recently as August, Erdogan was easily elected president in a first round of balloting with 52% of the vote. This is because the effects of slowing growth had not yet set in. Like most voters worldwide, what most Turks care about is their financial well-being. And the AKP’s record remains unsurpassed.

But the economy has lost steam since 2012. In a research note obtained by Al-Monitor, Goldman Sachs notes between 2012 and 2014, the Turkish economy “slowed down sharply” and the gross domestic product (GDP) grew by “a mere 2.8%.” The slowdown is attributed to external shocks, including the Arab Spring, the euro area sovereign debt crisis and the “Taper Tantrum” linked to the Fed’s long expected hike in interest rates. Last year’s fall in oil prices helped to shrink the current account deficit. But at 6% of GDP, it remains the highest among members of the OECD club.

Erdogan’s diatribes against the Central Bank have weakened investor confidence and contributed to the decline of the Turkish lira, which has shed almost 40% of its value against the dollar over the past two years. The president insists the bank must cut interest rates claiming — despite conventional theory, which suggests the opposite — that this will help bring inflation down.

The downturn has galvanized the moribund main opposition Republican People’s party (CHP). Its leader, Kemal Kilicdaroglu, who has been running an unusually lively campaign, is promising to double the minimum wage and various other perks. He has also promised to crack down on government sleaze.

Yet, most observers say that for all his recent setbacks, Erdogan remains the shrewdest — and most ruthless — politician on the block.

“He’ll do whatever it takes to win again,” said a veteran AKP official who now opposes Erdogan and declined to be identified for fear of reprisal. In a message sent to Al-Monitor via Twitter, the official added. “And once again the elections are all about him.”