Turkey's ban on Twitter ahead of bitterly contested elections sparked public fury over a "digital coup" on Friday, brought international condemnation and triggered a rift between prime minister and president.

Courts blocked access to Twitter after Prime Minister Tayyip Erdogan's defiant vow, on the campaign trail on Thursday ahead of March 30 local polls, to "wipe out" the social media service, whatever the international community had to say about it.

Industry Minister Fikri Isik said talks with Twitter were ongoing and the ban would be lifted if the San Francisco-based firm appointed a representative in Turkey and agreed to block specific content when requested by Turkish courts.

But tech-savvy Turks, President Abdullah Gul apparently among them, quickly found ways to circumvent the ban, with the hashtag #TwitterisblockedinTurkey rapidly moving to among the top trending globally.

"One cannot approve of the complete closure of social media platforms," Gul tweeted, voicing his hope that the ban would be short-lived and setting himself publicly at odds with the pugnacious prime minister.

Erdogan, who has dominated Turkish politics for 11 years, is battling a corruption scandal that has been fed by social media awash with alleged evidence of government wrongdoing. He did not mention the Twitter ban at two campaign rallies on Friday.

Turkey's main opposition party said it would challenge the ban and file a criminal complaint against Erdogan on the grounds of violating personal freedoms. The country's bar association filed a separate court challenge.

Twitter users called it a "digital coup", some comparing Turkey to Iran and North Korea, where social media platforms are tightly controlled. There were also calls for protests.

"Waking up to no Twitter in Turkey feels like waking up to a coup. The modern equivalent of occupying the radio stations," U.S. author and journalist Andrew Finkel, who has reported from Turkey for more than 20 years, said on his Twitter account.

The ruling AK Party has already tightened Internet controls, handed government more influence over the courts, and reassigned thousands of police and hundreds of prosecutors and judges as it fights the corruption scandal, which Erdogan has cast as a plot by political enemies to oust him.

Gul, seen as a more conciliatory figure than Erdogan, has been hesitant to openly criticize the prime minister in the run-up to the election, despite the brewing scandal and the latter's increasing claims of a conspiracy against his government.

The two co-founded the Islamist-rooted AK Party and Gul is seen as a potential successor to Erdogan should the latter run for the presidency in an August vote. His critics say his own ambitions have made him too cautious about challenging Erdogan, by far the most powerful figure in the ruling party.

EUROPEAN VALUES?

Telecoms watchdog BTK said Twitter had been blocked by the courts after complaints were made by citizens that it was breaching privacy. It said the social media service had ignored previous requests to remove content.

"Because there was no other choice, access to Twitter was blocked in line with court decisions to avoid the possible future victimization of citizens," it said.

European Union Enlargement Commissioner Stefan Fuele said the move raised grave concerns and "cast doubt on Turkey's stated commitment to European values and standards". Turkey has been seeking membership of the EU for decades.

The government of Germany, home to the largest Turkish diaspora in Europe, said the move did not fit with its view of freedom of expression, while the British foreign office said social media had a "vital role to play in a modern democracy".

Turkey's financial markets were unsettled, with the lira weakening to 2.24 against the dollar, shares underperforming emerging markets peers and the benchmark 10-year bond rising to 11.24 percent from 11.12.

Twitter said it was looking into the matter but had not issued a formal statement. The company did publish a tweet addressed to Turkish users instructing them on how to continue tweeting via SMS text message.

Erdogan was scathing about the service on Thursday.

"Twitter, mwitter!," he told thousands of supporters at a rally, in a phrase translating roughly as "Twitter, schmitter!".

"We will wipe out all of these," Erdogan said. "The international community can say this, can say that. I don't care at all. Everyone will see how powerful the Republic of Turkey is," he said in a characteristically unyielding tone.

Deputy Prime Minister Ali Babacan said he expected the block to be temporary while Finance Minister Mehmet Simsek also played down concerns, telling state broadcaster TRT Haber the closure "does not derive from a prohibitive mentality" and was nothing other than the application of a court ruling.

(Additional reporting by Seda Sezer, Daren Butler and Humeyra Pamuk in Istanbul, Gulsen Solaker and Jonny Hogg in Ankara, Guy Faulconbridge in London, Noah Barkin in Berlin and Edwin Chan in San Francisco; Editing by Jeremy Gaunt)