* Local elections have become test of Erdogan's standing after scandals
* Rivals hope to capitalise on months of political turmoil
* Strong results in Istanbul and Ankara could encourage presidency bid
* Setbacks might undermine Erdogan and entire political landscape
By Ralph Boulton
ISTANBUL, March 27 (Reuters) - To the adulation of the cheering crowds at his election rallies, Prime Minister Tayyip Erdogan paints a picture of an "evil alliance" plotting to topple him and break Turkey. In another place, on another day, his chief rival portrays him as a rogue doomed to jail or exile.
Sunday's local polls have taken on a significance far beyond what anyone could have dreamt before a graft scandal broke around Erdogan with police raids in December. Emerging from the harsh rhetoric of what can now scarcely pass as debate is a vision of two Turkeys that are scarcely compatible.
Elections will be held across Turkey, a Muslim NATO state of huge significance to Europe and the United States because of its place on the edge of a volatile Middle East; but Erdogan's fate is in essence a tale of two cities, the capital Ankara and the city seen as the treasure chest of Turkish politics, Istanbul.
"The polls this weekend are truly critical," a senior government official told Reuters.
"The results in Ankara and Istanbul will be serious indications of the future of the government as well as the decisions concerning presidential elections and early general elections," said the official, who declined to be named.
"Everyone knows that in this election it is not the parties that are being voted on, but Erdogan and his rivals."
As an ex-mayor of Istanbul himself, Erdogan is all too aware of this and has stepped up his campaign with evening rallies, his voice becoming hoarser as the days go by.
Sunday will be the first electoral test since a harsh crackdown on summer anti-government protests and a graft scandal fed by anonymous Internet postings of hacked Erdogan telephone calls. The prime minister accuses the secretive Islamic cleric Fethullah Gulen, who lives in the United States, of manipulating recordings to give the impression of corrupt acts.
"If AK loses Istanbul, he is in dire straits," said Today's Zaman newspaper commentator Yavuz Baydar, remarking on what he sees as silent concern about Erdogan among some in the party since the summer riots. "If he loses Istanbul, a lot of people will begin to stick their heads up out of the trenches."
FEAR OF RETURN TO CHAOS
Erdogan created the AK Party in 2001, a virtual 'emergency coalition' of conservative religious Muslims, nationalists and reforming centre-right elements. At polls a year later, it dealt a crushing blow to traditional secular parties mired in graft and economic failures from which they have yet to recover.
He remains the figure who holds AK together. Even opponents who wish him gone fear his departure could herald the disintegration not only of AK but also of the broader party political landscape, with a return to the chaotic coalitions and economic crises of the 1990s.
In the absence of reliable polls, the outcome in the European Union candidate state is uncertain.
Turkish stocks and the lira, hit by the graft scandal and the related power struggle with Gulen, rose on Wednesday on what traders saw as likely success for Erdogan's party, with the promise of a more settled political climate.
A vote significantly above the 40 percent that AK won in the last local elections in 2009 would probably secure Istanbul and Ankara, and could encourage Erdogan to run for the first directly-elected presidency in August.
That, however, would have its risks.
AK won almost 50 percent of the vote in the 2011 general election, but there are doubts whether he could match that to win outright in a first round of presidential polls. If opposition forces then united behind a single candidate in the runoff, Erdogan could lose.
Erdogan must also reckon with the unpredictable effects of further Internet postings. There is no firm evidence so far that the tapes have had any substantial effect on his popularity and supporters argue that, with their murky provenance and the implications for state security of hacking confidential state communications, they could even turn people against Gulen and rally them behind Erdogan.
If AK's support slips on Sunday, he might take the cautious path of changing party rules to allow him to run for a fourth term as prime minister in next year's parliamentary election.
The opposition CHP, having suffered three successive defeats to Erdogan, believes Turkey will turn against him over the graft scandal and his moves to purge the police force, strengthen the internal intelligence agency loyal to him and ban Twitter to impede the release of any more tapes.
A KIND OF COUP?
CHP head Kemal Kilicdaroglu said Erdogan was leading Turkey into another period of dictatorship.
"He will do or say anything because he is fighting for his life, because he knows full well what will happen if he loses power," he told Reuters at a rally. "He knows that he will be jailed. He would most likely have to flee the country."
Erdogan has criss-crossed Turkey excoriating his former ally Gulen as the engineer of a stream of anonymous Internet postings of tapped calls implicating him and his family in graft. Erdogan says the tapes were manipulated to give a false impression.
At a rally in Istanbul, he described Gulen's Hizmet network, which played a key role in Erdogan's early reforms, notable for pressing the army out of politics, as a terrorist organisation locked in an "alliance of evil" with the main opposition parties.
While the CHP, the nationalist MHP and the Kurdish BDP party hold their final rallies, none quite as colourful and dramatic as Erdogan's, Hizmet will not be visible on any podium, or anywhere else, for that matter.
Through its schools and business activities, Hizmet has over decades built up a covert network in most areas of state. Gulen compares it with a fully democratic pressure group, denies involvement in the police graft investigation and says he has no intention of forming a political party.
Polls suggest in any case it would gain few votes.
An official close to Erdogan, who asked not to be named, acknowledged the role played by Gulen in ending "tutelage" - a reference to the breaking of the political power of an army that had toppled four governments in 40 years. But he said that, by 2011, Erdogan realised "a problem was in the making".
"Right now, what's going on is a struggle for Erdogan and the future of Turkey. (Hizmet) wants to finish off the prime minister."
In that struggle, Erdogan has removed more than 6,000 public servants in the lst few months.
"Certainly there's been a negative impact of the fight," the official said. "They truly were acting under orders from the Gulen Congregation.
"It does sound like a coup, but if this hadn't been done, whatever one may call it, the future of this government and all other governments to come would have been totally at risk." (Additional reporting by Ayla Jean Yackley and Orhan Coskun; Editing by Nick Tattersall and Kevin Liffey)
Our Standards: The Thomson Reuters Trust Principles.