ISTANBUL Prime Minister Tayyip Erdogan has an unspoken pact with the Turkish electorate: he delivers rapid economic growth, jobs and money, and voters let him shape what kind of democracy this Muslim nation of 74 million people becomes.
So far, the deal has served him well.
Erdogan has overseen a near tripling of per capita income in the last decade. That has helped blunt misgivings over the way he deals with dissent, and allowed him to subordinate Turkey's powerful military, which has long seen itself as guardian of the country's secular soul. Last year he used a plebiscite on constitutional reform to break the cliques in the judiciary, another bastion of Turkey's secular old guard.
The prime minister's Justice and Development Party (AKP), socially conservative and successor to a banned Islamist party, won a third term with 50 percent of the vote in parliamentary elections in June thanks largely to the success of its pro-growth free-market policies.
"Erdogan realizes he will be in power as long as the country prospers," Umit Ozlale, an economics professor at TOBB University in Ankara said. "When the economy is on track he handles other challenges from the military, judiciary or from the bureaucracy more easily."
At the same time, many Turks have a sneaking feeling that the prime minister's road to democracy will always lead to his own party. With the economic boom now wobbling and the resignation on July 29 of the country's four most senior generals, tensions at the heart of Erdogan's Turkey are becoming harder to ignore.
"The fear amongst many of the (AKP's) critics in Turkey is that the party is now overly dominant with fewer checks and balances given its controls all the main levers of the state," said Timothy Ash, an analyst at Royal Bank of Scotland.
BEATING THE GENERALS
When Chief of General Staff Isik Kosaner stepped down late last month along with the heads of the army, military and navy, he said he could no longer stand by while 250 fellow officers languished in jail, victims of charges he described as flawed and unjust.
The capitulation of the top brass confirmed what most Turks have known for years: the generals are a spent force in Turkish politics.
In many ways, that's progress. Generals overthrew three civilian governments between 1960 and 1980 and forced an Islamist-led coalition of which Erdogan was part from power in 1997. Turks respect their military, but most want to keep the uniform out of politics.
Erdogan has managed to do just that. In 2007, the military failed to stop the AKP government installing Abdullah Gul as president. That same year, Erdogan won a second term as prime minister in a parliamentary poll that let the military know they should stop messing with democracy.
That's created a new dynamic between soldiers and politicians. The new generals Erdogan selected last week may not love the AK Party, but they're unlikely to ignore fellow officers plotting against the government. When Erdogan chaired a meeting of the Supreme Military Council a few days after the resignations there was no doubting who was in charge. Flanked by grim-faced four-stars, Erdogan sat alone at the top of the table, where he would normally be joined by the chief of general staff.
MAN OF THE PEOPLE
Erdogan's followers like his forceful personality and the fact he grew up in Istanbul's rough Kasimpasa neighborhood, where boys learn to carry themselves with a swagger and have the last word in any argument.
More than that, they appreciate his piety and sense of justice that some ascribe to his studies of Islam. Many see him as uncorruptible.
He connects with ordinary people, using everyday language in his speeches and addressing members of the audience with comments like: "Isn't that the case, sister?," "Don't you think so, dear mother?"
They also like that he's engineered a shift in power away from the old Istanbul-based business houses to the so-called Anatolian tigers in the more conservative heartland of Turkey.
And his appeal goes well beyond Turkey.
The tongue-lashing he gave Israeli president Shimon Peres at Davos in 2009 over the Gaza offensive, cemented his reputation in the Islamic world.
Last December, just before the uprising in Tunisia started the Arab Spring, a taxi driver in Tunis pointed to a photograph of Erdogan in a newspaper. "Nice man," the cabbie told a Reuters journalist. "The best leader in the Islamic world right now."
THREE TIMES A WINNER
Turkey's prime minister has long understood that the key to success is economic growth.
Over the past decade he's transformed Turkey from a basket case dependent on IMF loans to the 16th largest economy in the world. He wants Turkey to be in the top 10 by 2023.
Flush with money and with their own economy faring far better than the euro zone, Turks have grown less enamored of the prospect of joining the European Union.
Last year Turkey notched up 9 percent growth. An Istanbul banker tells a story about a customer who wanted a loan. When asked how many siblings he had in his family the young man said: "We are four, but God has given us Tayyip, so now we're five."
There is a sense that as long as Erdogan keeps Turks in jobs and the money rolling in, people won't mind if the AKP government loses some of the democratic zeal that marked its early years. Erdogan has been very open about his plans for a new constitution that could open the way for him to become president.
Chances of the opposition unseating him are remote, and he has no real rivals within the AKP.
Sinan Ulgen, chairman of the Center for Economics and Foreign Policy Studies (EDAM), an Istanbul- and Brussels-based think tank, reckons the greatest risk to Erdogan's dominance is an economic crisis brought on by an external shock.
"Until then the AKP has a blank check," he said, speaking just before the latest market turmoil. "This situation can continue as long as international markets remain benign, as long as interest rates globally remain low, as long as risk aversion remains low."
"THE FINAL WORD"
That is a dismal prospect for members of the old elites, who fear Erdogan's AKP aims to roll back the secular state envisioned by soldier-statesman Mustafa Kemal Ataturk when he founded the republic after the collapse of the Ottoman Empire.
Erdogan has already been in office longer than any other leader since Ataturk. Critics refer to the possibility he will rule on as president as the "Putinisation" of Turkey, though the term is seldom seen in the press.
When foreign diplomats in Ankara are asked what action Turkey might take on an issue, the answer is often along the lines of: "In the end Erdogan will have the final word."
Normally it would fall to the judiciary and press to provide a check on the government. But Turkey's judges and journalists have also had their wings clipped.
Only last year, Erdogan won backing in a referendum on constitutional reforms that included changes to the way judges are selected. There's little doubt that the judiciary needed reforming, but critics say that the changes also reduced judges' independence.
Turkey has fallen to 138th out of 178 countries in the World Press Freedom Index produced by media freedom pressure group Reporters without Borders, from 101st in 2007. Washington and Brussels have both aired concerns.
Early this year, with the election looming, police detained around a dozen journalists said to be linked to an alleged anti-government network dubbed Ergenekon, the fabled valley of Turkish legend from where a tribe of Turks escaped their enemies by following a lone wolf.
Opposition politicians and military leaders allege some prosecutors are taking revenge for past state repression of Islamist movements. Armed with leaks from either prosecutors or the police, government-friendly media report the detentions in ways that suggest the suspects are guilty before their cases are heard.
"Many people worry that the arrests of these officers and journalists may be the product of a witch-hunt mentality by those who feel they have the power now and are using the judiciary to settle old scores," said Hurriyet Daily News columnist Semih Idiz.
Since coming to power, Erdogan has gone out of his way to be seen as a model of pragmatism. Alcohol may cost more, but little in the way of legislation offers evidence of a religious agenda.
An attempt to lift a ban on women wearing the Muslim headscarf entering universities or working in the public sector has not been revived since it was pushed back in 2004.
In the past year, however, there was barely a murmur when universities began taking a permissive stance toward students in headscarves.
Scaremongering over the spread of Islamism proved a vote- loser for the secular opposition, so they stopped campaigning on it, opting instead to pick holes in Erdogan's image as a champion of democracy.
The pillar of his political program is a proposal for a new constitution to replace the one drafted after a 1980 military coup. Parliament is expected to begin work on the new charter in October, and it is likely to dominate the political agenda until next summer.
"It will be a constitution emphasizing pluralism rather than a single voice. It will take the individual and their rights as its basis, protecting national unity and our shared values and accepting the wealth of social diversity," Erdogan said late last month.
Critics are unconvinced. When Erdogan has said in the past "democracy is not an objective, it is a vehicle," his foes have pounced, pointing to the words as proof of his autocratic tendencies.
"The new constitutional order will bring not liberty and democracy, as the government is trying to persuade Westerners, but a harsher new order," former Constitutional Court chief judge Yekta Gungor Ozden told Reuters.
WHAT KIND OF PRESIDENT?
But the shape of a new constitution is far from clear. Burhan Kuzu, the head of the parliamentary commission looking at it, is a staunch advocate of the presidential system and argues that Turkey prospers from single-party rule and slips back when led by weak coalitions.
Not everyone in the AKP likes the idea of a presidential system: to win the parliamentary votes he needs to alter the constitution, Erdogan will have to reach out to rival parties.
Former justice minister Hikmet Sami Turk told Reuters that many opposition groups will not "accept a presidential system. It could lead to a dictatorial system."
If Erdogan fails to win his changes, he will likely still run for -- and win -- the presidency in 2014 even if the position remains a figurehead role.
His greatest threat is an economic crisis.
Against conventional wisdom, the central bank cut its policy interest rate to an all-time low on August 4, despite growing concerns about inflation and pressure on the lira currency.
In the last few months, Erdogan said that ideally he'd like to see real interest rates at zero, a notion that makes some worry that populist priorities could hurt the economy.
If inflation rises or the flow of foreign investment dries up, Turkey could easily find itself with a current account deficit climbing beyond 10 percent of GDP, leaving it vulnerable to an economic shock that could persuade voters to desert Erdogan just as they did his predecessors.
Until then, there's no doubting who's boss.
(Reported and written by Simon Cameron-Moore and Daren Butler; Additional reporting by Asli Kandemir, Tulay Karadeniz, Orhan Coskun, Ozge Ozbilgin and Pinar Aydinli; Editing by Simon Robinson and Sara Ledwith)