* Government suffers court setback on police inquiries
* PM pledges electoral "war" as graft scandal swirls
* Erdogan says targeted through son in investigation
* Turkish military says judiciary's independence key
By Orhan Coskun and Ece Toksabay
ANKARA/ISTANBUL, Dec 27 Protesters demanding Turkish Prime Minister Tayyip Erdogan resign over a high-level corruption scandal clashed with riot police in Istanbul on Friday, while across the city thousands staged a rival show of support for the embattled leader.
Around Taksim Square, centre of anti-government demonstrations last summer, police fired tear gas and used water cannon against hundreds of protesters chanting "There are thieves".
Erdogan faces a crisis unprecedented during his 11 years in office due to the scandal that has forced three ministers' resignations and a cabinet reshuffle, as well as destabilising the Turkish economy whose rapid growth has been a showpiece of his rule.
However, Erdogan still enjoys the loyalty of many pious Muslims and members of Turkey's wealthy elite. While police tried to prevent anti-Erdogan crowds from forming on Taksim, cheering supporters of the ruling AK Party welcomed him at Istanbul airport about 20 km (14 miles) away, waving party and national flags when he returned from a trip to the provinces.
Police detained dozens of people on Dec. 17, among them the sons of the interior minister and two other cabinet members, after a major graft inquiry that was kept secret from commanders who might have informed the government in advance.
Earlier on Friday, Erdogan suffered a setback in his efforts to contain the fallout from the scandal when a court blocked a government attempt to force police to disclose investigations to their superiors.
The regulation that would have made police officers inform their superiors about investigations was announced by the government, angered at having been kept in the dark about the year-long corruption inquiry.
Financial markets reacted nervously on Friday to the scandal. The lira currency hit a record low, stocks were at their weakest in 17 months and the cost of insuring the country's debt against default jumped to an 18-month high.
The affair turned more personal this week when Turkish media published what appeared to be a preliminary summons for Bilal Erdogan, one of the premier's two sons, to testify, although its authenticity could not immediately be verified.
Denying wrongdoing, the Erdogan government purged about 70 of the police officers involved, including the head of the force in Istanbul, and issued a new rule on Dec. 21 requiring police investigators to share their findings with their superiors.
The Council of State, an Ankara court that adjudicates on administrative issues, blocked implementation of the regulation, ruling that it "contradicts the principle of the separation of powers".
With speculation rife in his party that he might call early general elections next year, Erdogan urged supporters to vote in a March local polls as part of a "war" on what he says is a foreign-orchestrated plot cloaked as criminal proceedings.
In a speech in Sakarya province, a heartland of his Islamist-rooted AK party, Erdogan likened ballots to bullets.
"You, with your votes, will foil this evil plot," he told the cheering crowd. "Are you committed to establishing a new Turkey? Are you ready for Turkey's new independence war?"
RALLYING THE TROOPS
He was referring to local elections three months away, in which some disappointed AK faithful might abandon the party.
AK controls two-thirds of parliament and pollsters see a modest blow to the party's base but say it could spiral if the scandal gets worse. One AK official, speaking to Reuters on condition of anonymity, predicted Erdogan could bring forward the scheduled 2015 general election to arrest such a slide.
In another dent to the party's prestige, three of its lawmakers stepped down on Friday. One of them, Ertugrul Gunay, complained of a "domineering and arrogant attitude" in AK.
Among Erdogan's past feats was pruning the power of the military, once the country's dominant authority and guardian of its secularist constitution, by championing the prosecution of scores of senior officers on putsch and terrorism allegations.
In an implied rebuke to Erdogan, the military said on Friday it had respected the judiciary's independence at the time. "The legal proceedings regarding Turkish armed forces personnel were observed in accordance with the duties and responsibilities laid out in the law," the chief of staff said.
On Thursday, a Turkish prosecutor, Muammer Akkas, said he had been removed from the corruption case and accused police of obstructing it by failing to execute his arrest warrants.
Turkey's chief prosecutor responded that Akkas was dismissed for leaking information to the media and failing to give his superiors timely updates on progress.
The government's attempts to impose new regulations on the police anger some Turks who see an authoritarian streak in Erdogan and flooded the streets in mass protests earlier this year.
The court ruling echoed an advisory issued the day before by the High Council of Judges and Prosecutors, a body which handles court appointments independent of the government.
Those jurists were excoriated by Erdogan on Friday.
"The High Council of Judges and Prosecutors has committed a crime," he said at Sakarya University after receiving an honorary doctorate. "Now I ask: Who is going to try this council? If I had the authority, I'd do it right away."
The putative Bilal Erdogan summons appeared to have come from a prosecutor's office but was unsigned. Hurriyet quoted Erdogan as saying he was the target of those naming Bilal.
"If they try to hit Tayyip Erdogan through this, they will go away empty-handed. Because they know this, they're attacking the people around me," he said.