ANKARA, Turkey — Turkish Prime Minister Recep Tayyip Erdogan on Wednesday reshuffled his cabinet after three key ministers resigned over a sweeping corruption and bribery scandal that has targeted his allies and rattled his government.

Erdogan replaced Economy Minister Zafer Caglayan, Interior Minister Muammer Guler and Erdogan Bayraktar, the minister for the environment and urban planning. All three men’s sons were detained as part of the corruption investigation. They all deny any wrongdoing.

Erdogan also replaced the minister in charge of relations with the European Union, who was also been implicated in the scandal, but has not resigned.

In all, Erdogan replaced 10 ministers, including three who will contest mayoral elections in March.

In Istanbul, police clashed with hundreds of protesters demanding the government’s resignation, Dogan news agency reported.

The corruption probe is one of the biggest political challenges Erdogan has faced since his Islamic-based party narrowly escaped being disbanded in 2008 for allegedly undermining Turkey’s secular Constitution. This summer, he also weathered a wave of anti-government protests sparked by a development project that would have engulfed an Istanbul park.

Erdogan has denounced the investigation as a plot by foreign and domestic forces to thwart his country’s prosperity and discredit his government ahead of local elections in March. His government has won three elections since 2002 on the strength of the economy and a promise to fight corruption.

He had ignored opposition calls for the immediate dismissal of the ministers.

On Tuesday, Turkish President Abdullah Gul had signaled that the government ministers embroiled in the corruption and bribery scandal could be removed from their posts.

Asked if the ministers involved would be removed, Gul said Tuesday that Erdogan was “making preparations and assessments” on the issue. The president approves ministerial appointments.

Last week, 24 people were arrested on bribery charges as part of the probe, including the head of a state-run bank, with suspected ties to sanctions-hit Iran.

Police said they seized shoeboxes stashed with $4.5 million in cash at the home of the chief of Halkbank while more than $1 million in cash was reportedly discovered in the home of Guler’s son.

According to Businessweek, “police have said the inquiry targets organized graft, money laundering and gold smuggling.”

The police raids threatened to rock Erdogan’s 11-year tenure.

Many believe the police operation is the fallout of a deepening rift between Erdogan’s government and a powerful US-based moderate Islamic cleric, Fethullah Gulen, whose followers are reported to have a strong foothold within Turkey’s police and judiciary.

Gulen has denied being involved in the investigation. He left Turkey in 1999 after being accused by the then-secular government of plotting to establish an Islamic state. He was later cleared of that charge and allowed to return to his homeland, but he never has and is living in Pennsylvania.

Erdogan has said the corruption investigation is a “dirty operation” to unsettle his government and has vowed to go after those who have instigated it. The Turkish PM has also indicated that there was an “international dimension” to the probe.

On Saturday, Erdogan had threatened to expel foreign ambassadors from Turkey, following what he termed “provocative actions” on their part amid the ongoing corruption investigation.

“Some ambassadors are engaged in provocative actions … Do your job,” Erdogan said in televised remarks.

“We don’t have to keep ambassadors in the country who exceed the limits of their duty,” he added.

Erdogan did not name names but the remarks were considered a warning to US Ambassador to Turkey Francis Ricciardone, who, according to pro-Erdogan media outlets, had told EU envoys that Washington had advised Halkbank to cut ties with Iran.

“We asked Halkbank to cut its links with Iran. They did not listen to us. You are watching the collapse of an empire,” Ricciardone was quoted as telling EU ambassadors, according to remarks carried by AFP based on reports in Aksam, Bugun, Yeni Safak and Star newspapers.

Ricciardone on Saturday denied the media reports as “baseless allegations,” in his Twitter account in the Turkish language. ”Nobody should put US-Turkish relations into jeopardy through baseless allegations,” he said, according to AFP.