Turkish Prime Minister Recep Tayyip Erdogan replaced nearly half his cabinet in a dramatic reshuffle late Wednesday after a spreading graft scandal forced the resignation of three top ministers and threatened the premier’s own hold on power.

Erdogan announced on television he had replaced those three ministers — for the interior, economy, environment — as well as his EU affairs minister, and reshuffled the justice, transport, family, sports and industry portfolios, and one of his four deputy prime ministers’ posts.

The reshuffle was decided in a closed-door meeting with President Abdullah Gul, who had said since Tuesday that it was imminent.

There was no indication the characteristically defiant prime minister was himself contemplating stepping down, as demanded by anti-government protesters — and by the environment minister who resigned, Erdogan Bayraktar.

Yet the corruption scandal is rapidly becoming a major challenge to Erdogan’s 11-year grip on power in Turkey, a NATO member and significant emerging economy.

His image was already badly bruised in June when he ordered a heavyhanded crackdown on anti-government protests sparked by plans to raze an Istanbul park.

Another protest took place in Istanbul on Wednesday demanding Erdogan’s ouster, but police used tear gas to disperse the estimated 5,000 demonstrators after some skirmishes. Protests were also reported in Ankara and Izmir.

The probe into the corruption, which has seen recent police raids, focus on allegations of numerous offences including accepting and facilitating bribes for construction projects and illegally smuggling gold to Iran.

Erdogan himself has sought to define the corruption scandal as “a conspiracy” plotted by “international powers”.

He insists his ruling Justice and Development Party (AKP) party has a clean record and has responded to the investigation by sacking dozens of police chiefs.

Rift seen with erstwhile ally

Observers see the probe as the result of a rift between Erdogan and a former major ally, Fethullah Gulen, a Muslim cleric who lives in the United States and whose movement wields considerable influence in Turkey’s police and judiciary.

Gulen, who denies being behind the graft investigation, is thought to be at odds with Erdogan, a conservative and Islamic-leading leader, after the government moved to shut down a network of Gulenist schools — a major source of revenue for his group.

Gulenists were previously key backers of the AKP, helping it to win three elections in a row since 2002.

The growing row could have an impact on March 30 local elections and on presidential elections in August that many believed Erdogan was keen to enter.

The scandal hit a politically critical level when the sons of the previous interior and economy ministers were among two dozen people to be charged in the wide-ranging bribery and corruption probe, which has also ensnared close government allies and top businessmen, including the chief executive of state-owned Halkbank.

The environment minister’s son was also detained last week, but has not been formally charged and has been released pending trial.

Both Caglayan and Guler have rejected the bribery accusations against their sons.

But Bayraktar raised the stakes by calling Erdogan to follow suit by resigning — the first time the popular prime minister has faced such a challenge from a minister in his own party.

“I believe the prime minister should also resign,” Bayraktar told the private NTV television, alleging that the vast majority of construction projects mentioned in the investigation were carried out with the premier’s approval.

“A big majority of construction plans in the investigation dossier were carried out with the approval of the prime minister,” he said.

As Bayraktar was speaking live, the channel its feed, raising a stir on Twitter, where critics slamming it as censorship.

In his reshuffle later on, Erdogan named Idris Gulluce as his new environment minister; an interior ministry undersecretary, Efkan Ala, his new interior minister; and Nihat Zeybekci his economy minister.

Meanwhile, in an apparent widening of the graft investigation, prosecutors in Ankara said they had opened a probe into the national rail authority over corruption claims in public tenders. No arrests have yet been made, the prosecutor’s office said.

The tensions have clearly hurt the already slowing Turkish economy, pushing the national currency to record lows against the US dollar.

The lira weakened to 2.0907 against the dollar at Wednesday’s close. The Istanbul stock market plummeted by 4.2 percent to 66,096.56.