* Erdogan rally marks final drive to March 30 elections
* Anonymous recordings on YouTube purportedly expose graft
* Erdogan locked in power struggle with former ally (Updates with details of rally)
By Nick Tattersall and Humeyra Pamuk
ISTANBUL, March 23 (Reuters) - Turkish Prime Minister Tayyip Erdogan, rallying hundreds of thousands of cheering supporters in Istanbul, said on Sunday that political enemies accusing him of corruption would be crushed by their own immorality.
The rally on the shores of the Sea of Marmara marked the climax of weeks of campaigning for March 30 local polls that may decide his political fate. Tens of thousands more gathered outside the rally grounds and clambered over fences to get in.
Massed supporters cheered, called Erdogan's name and waved red Turkish flags and the blue and gold emblems of the AK Party he founded in 2001 and led to power a year later vowing to root out the corruption that had dogged his rivals.
As the vote nears, audio tapes of telephone conversations have appeared on websites almost daily purporting to expose corruption around Erdogan.
The prime minister accuses the U.S.-based cleric Fethullah Gulen and his followers of manufacturing a police corruption investigation that touched on business associates, government members and Erdogan's own family.
"Whatever threats, blackmail or slander you throw out, you will be crushed beneath the immorality of these montages," Erdogan said from a platform flanked by banners with his portrait. "The people can see the game that is being played."
The size of the crowd, which he put at 2 million, suggested AK Party was well placed to keep control of Istanbul. Loss of the city would be a serious personal blow for Erdogan.
The Republican People's Party (CHP), the chief opposition group, would struggle to bring out anything like that number. But the CHP could claim a significant victory in taking Ankara.
The ramifications of the turmoil in a country long held up by Washington as an example of a Muslim democracy that could anchor the Middle East are broad. On the economic front, the consumer confidence index fell to its lowest in four years last month, interest rates have risen and the lira has weakened.
Erdogan described the influential Hizmet network of Gulen, who lives in self-imposed exile in Pennsylvania, in a speech on Saturday as a terrorist organisation.
Turkey blocked the Twitter social networking site, a vehicle for many of the audio tapes, last week, drawing accusations from Western governments and rights groups of an attack on democratic values. Erdogan responded at a smaller rally earlier on Sunday.
"The usual media are attacking us. What do they call it? 'Intolerance of freedoms'," he said. "I don't care who it is, I'm not listening.
"This entity called Twitter, this YouTube, this Facebook, they have shaken families to their roots ... I don't understand how people of good sense could defend this Facebook, YouTube and Twitter. There are all kinds of lies there."
There is widespread expectation of further postings intended to damage Erdogan, who denies all graft accusations.
These could emerge ahead of the local polls, where any result much below the 40 percent achieved by AK five years ago could weaken his prospects of being elected president in July.
But they could also emerge during the presidential election period itself. A poor result next week could revive concern that emerged over his hard line against protesters last summer.
FORMER ALLY GULEN
Ultimately, much could hinge on the opposition regaining the leadership and momentum it has lacked since 2002. Back then, Erdogan drew on public anger over corruption in Turkey's old political elite and named his new party AK, an acronym for Justice and Development but also a word meaning clean or white.
Gulen is widely believed to have played a key role helping Erdogan to rein in the military that toppled four governments in 40 years, by using his influence in the police and judiciary to bring generals to trial. But the two fell out over Gulen's influence, which Erdogan says amounts to a parallel state.
Erdogan has shut down Gulen's network of cramming schools, a major source of income and influence for Hizmet. He has purged the police and judiciary of Gulenists and blocked a bid by Gulen to extend his influence into the intelligence service, MIT.
Gulen, who denies any scheming against Erdogan, says he has no plans to form a party of his own. The prime minister accused the CHP, the nationalist MHP and the Kurdish BDP party at the weekend of forming an "alliance of evil" to undermine him. (Additional reporting by Daren Butler, Seda Sezer in Istanbul; Writing by Ralph Boulton; Editing by Tom Heneghan)