* Moody's cites politics, weaker growth for outlook cut
* Constitutional court ruling clips Erdogan's wings
* Lira, stocks down, bond yields up (Adds justice minister, opposition and analyst comment)
By Gulsen Solaker and Orhan Coskun
ANKARA, April 11 (Reuters) - Turkish Prime Minister Tayyip Erdogan suffered a double blow on Friday when a court rolled back his government's efforts to tighten its grip on the judiciary and Moody's cut its outlook for the economy on which for many his reputation stands.
Erdogan has divided opinion at home and unnerved Western governments with his response to a corruption scandal swirling around his inner circle since December, removing thousands of police and judiciary officials and blocking social media sites.
His ruling AK Party's victory in municipal elections on March 30, despite the scandal, reassured nervous financial markets, but also raised the political stakes ahead of an August presidential election and parliamentary polls next year.
Cutting its sovereign outlook on Turkey to negative, Moody's said political uncertainty would weigh on weak points in its economy, notably its high external financing needs, throughout the voting cycle, damaging its growth prospects.
"Moody's expects these tensions in the political arena to persist until at least the second quarter of 2015, when parliamentary elections are due," the agency said.
Erdogan's support among Turkey's masses is partly based on his Islamist-rooted ideology but also on a reputation for economic management. His AK Party delivered a decade of strong growth after unstable coalition governments in the 1990s ran into repeated balance of payments problems and economic crises.
It is a reputation he may find increasingly hard to maintain as the economy slows, inflation remains stubbornly high and consumer confidence slides. The lira currency, Turkish stocks and bonds all lost ground following the Moody's announcement.
Development Minister Cevdet Yilmaz suggested Moody's had misjudged the political mood.
"With the latest elections, Turkey's political stability was confirmed once again. This was expected to have positive reflections on credit ratings," he said.
Threats to confidence in state institutions as Erdogan fights a power struggle with influential U.S.-based cleric Fethullah Gulen, a former ally he accuses of contriving the corruption scandal, could also unnerve the foreign investors on whom Turkey depends to fund its wide current account deficit.
In the latest move in a struggle over influence in the judiciary, the constitutional court said it had cancelled articles in a new law that had granted the justice minister powers over the High Council of Judges and Prosecutors (HSYK), which makes judicial appointments.
The ruling was a victory for opposition parties which had said the law violated the constitution and was an attempt to stifle graft inquiries. Justice Minister Bekir Bozdag said the government would comply but defended the legislation.
"The regulation we prepared conforms with the constitution. The constitutional court's cancellation decision has not changed my opinion. But of course we will abide by the court's decision," he told reporters.
"STORING UP TROUBLE"
The corruption scandal, which erupted in December with police raids that targeted the sons of ministers and businessmen close to Erdogan, has raised concerns in the West about Turkey's democratic credentials and presented the prime minister with his biggest challenge during 12 years in power.
Fadi Hakura of London-based think-tank Chatham House said the constitutional court appeared to be one of few institutions in Turkey that remained truly independent, although he said Friday's ruling had come too late to prevent the government from making the changes it wanted in the judiciary.
"If you look at the law, the government knew that the constitutional court would strike it down because it's contrary to the constitution," he told Reuters. "But in the interim it allowed the government to remove a lot of people from the courts and replace them with their own people."
Following his party's local election win, Erdogan declared he would punish those responsible for the corruption scandal, which saw a stream of audio recordings leaked onto social media sites including Twitter and YouTube, purportedly showing government wrongdoing.
The law granting the justice minister extra powers was part of what Erdogan has characterised as a campaign to root out a subversive "parallel state" of Gulen's followers, whom he accuses of using their influence within the police and judiciary to try to seize the levers of state power.
Gulen denies this.
"The constitutional court showed the government and everyone that nobody can play with the law according to their whims," said Engin Altay, a deputy with the main opposition CHP party which had called for the law's annulment.
The political wrangling, expected to intensify as the August presidential race approaches, puts a risk premium on Turkey that is likely to persist in the months ahead, analysts say.
"While the timing of the cut in the outlook on Turkey's rating is at odds with the recent improvement in sentiment, it's a reminder, if one were needed, that Turkey remains one of the most vulnerable emerging markets," said Nicholas Spiro, head of Spiro Sovereign Strategy.
"Although last week's local elections were preceded and followed by a market rally, the victory of the AK Party is merely storing up trouble for the future."
(Additional reporting by Jonny Hogg in Ankara, Daren Butler, Ece Toksabay and Seda Sezer in Istanbul; Writing by Nick Tattersall; editing by Ralph Boulton)